内容简介:翻译自:https://stackoverflow.com/questions/2327864/converting-nsnetservice-addresses-to-ip-address-string
这个问题已在这里提出:
NSNetservice IP address我已经用这两个来达到我现在的位置.我的问题是以下方法我不太有用:
- (NSString *)getStringFromAddressData:(NSData *)dataIn {
struct sockaddr_in *socketAddress = nil;
NSString *ipString = nil;
socketAddress = (struct sockaddr_in *)[dataIn bytes];
ipString = [NSString stringWithFormat: @"%s",
inet_ntoa(socketAddress->sin_addr)]; ///problem here
return ipString;
}
这给出了一个构建错误,说明在同一行上“解除指向不完整类型的指针”和“隐式声明函数’inet_ntoa’”.
我已经检查过,我不认为我错过了某种类型的框架来让inet_ntoa工作.知道我做错了什么吗?谢谢.
如果你得到inet_ntoa的隐式声明,你可能需要
#include <arpa/inet.h>
(您可以通过man inet_ntoa获取此信息并阅读有关该功能的更多信息)
翻译自:https://stackoverflow.com/questions/2327864/converting-nsnetservice-addresses-to-ip-address-string
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 查找一个字符串中最长不含重复字符的子字符串,计算该最长子字符串的长度
- 字符串、字符处理总结
- 高频算法面试题(字符串)leetcode 387. 字符串中的第一个唯一字符
- php删除字符串最后一个字符
- (三)C语言之字符串与字符串函数
- 算法笔记字符串处理问题H:编排字符串(2064)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Game Engine Architecture, Second Edition
Jason Gregory / A K Peters/CRC Press / 2014-8-15 / USD 69.95
A 2010 CHOICE outstanding academic title, this updated book covers the theory and practice of game engine software development. It explains practical concepts and techniques used by real game studios,......一起来看看 《Game Engine Architecture, Second Edition》 这本书的介绍吧!