Last active
December 10, 2015 20:58
-
-
Save blankyao/4491470 to your computer and use it in GitHub Desktop.
get ip address by hostname from iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct hostent *host = gethostbyname(@"localhost".UTF8String); | |
char addr[32]; | |
inet_ntop(host->h_addrtype, host->h_addr, addr, sizeof(addr)); | |
NSString *result=[[NSString alloc] initWithUTF8String:addr]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment