I need to resolve an IP address from a hostname in iOS. I know this is trivial using NSHost, however NSHost resolution capability seems to only work on OSX.
Thanks in advance.
Like this:
struct hostent *host_entry = gethostbyname("stackoverflow.com");
char *buff;
buff = inet_ntoa(*((struct in_addr *)host_entry->h_addr_list[0]));
buff variable now contain an ip address...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With