Basically, the inet_addr () function does not resolve the domain name for you. You need to give it an IP address (for example, 127.0.0.1).
To resolve the DNS name to IP address, you need to look at the standard gethostbyname () functions.
To clarify:
struct hostent *host = gethostbyname("fr7.mooshroom.net"); if (host) { struct in_addr in; NSLog(@"HOST: %s" , host->h_name); while (*host->h_addr_list) { bcopy(*host->h_addr_list++, (char *) &in, sizeof(in)); NSLog(@"IP: %s", inet_ntoa(in)); } }
Now, having said all this, are you sure that this will do what you want? The documentation for SCNetworkReachabilityRef does not imply:
http://developer.apple.com/library/ios/#documentation/SystemConfiguration/Reference/SCNetworkReachabilityRef/Reference/reference.html
"A remote host is considered accessible when a data packet sent by the application to the network stack can leave the local device. Accessibility does not guarantee that the data packet will indeed be received by the host."
source share