#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
/// 解析域名
- (NSString *)resolveDomain:(NSString *)domain {
struct hostent *hs;
struct sockaddr_in server;
if ((hs = gethostbyname([domain UTF8String])) != NULL) {
server.sin_addr = *((struct in_addr*)hs->h_addr_list[0]);
NSString *ip = [NSString stringWithUTF8String:inet_ntoa(server.sin_addr)];
return ip;
}
/// 默认 IP
return @"58.250.243.61";
}