ios - how to resolve the hostname of a device in my LAN from its ip address on this LAN? -
i have resolve hostname of device in lan ip address on lan. have code works external ip address not internally connected devices .
below have attached code .
if have idea hostname of remote machine it's ip in ios/osx, it'll make day.
int error; struct addrinfo *results = null; error = getaddrinfo("173.194.34.24", null, null, &results); if (error != 0) { nslog (@"could not info address"); } (struct addrinfo *r = results; r; r = r->ai_next) { char hostname[ni_maxhost] = {0}; error = getnameinfo(r->ai_addr, r->ai_addrlen, hostname, sizeof hostname, null, 0 , 0); if (error != 0) { continue; // try next 1 } else { nslog (@"found hostname: %s", hostname); break; } } freeaddrinfo(results);
or nshost
nslog(@"%@ \n%@",[nshost currenthost],[[nshost hostwithaddress:@"172.17.241.61"] names]);
only way make dns lookup directly specific dns implement protocol or use library.
https://serverfault.com/questions/173187/what-does-a-dns-request-look-like
Comments
Post a Comment