iphone - Find the device(IP camera) IP address present in LAN network using iOS device? -
i working on project, has find camera ip-address connect in lan network, using lan search ios find camera, works times camera has self assigned (169.254.164.xxx) default ip address. lan search can’t find it. how can find camera present in lan network, though camera in default network?
this returns local ip address:
- (nsstring *)getipaddress { nsstring *address = @"error"; struct ifaddrs *interfaces = null; struct ifaddrs *temp_addr = null; int success = 0; // retrieve current interfaces - returns 0 on success success = getifaddrs(&interfaces); if (success == 0) { // loop through linked list of interfaces temp_addr = interfaces; while(temp_addr != null) { if(temp_addr->ifa_addr->sa_family == 2) { // check if interface end wifi connection on iphone if([[nsstring stringwithutf8string:temp_addr->ifa_name] isequaltostring:@"en0"]) { // nsstring c string address = [nsstring stringwithutf8string:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)]; } } temp_addr = temp_addr->ifa_next; } } // free memory freeifaddrs(interfaces); return address; }
Comments
Post a Comment