How to resolve and hostname IP address on iOS

I need to resolve the IP address from the hostname in iOS. I know this is trivial with NSHost, however NSHost's resolution capabilities seem to work only with OSX.

Thanks in advance.

+4
source share
2 answers

Like this:

struct hostent *host_entry = gethostbyname("stackoverflow.com"); char *buff; buff = inet_ntoa(*((struct in_addr *)host_entry->h_addr_list[0])); 
In variable

buff now contains ip address ...

+14
source

All Articles