STUN-iOS project can not show public IP -
now have problem stun protocol on ios. downloaded project on github https://github.com/soulfly/stun-ios however, when running project. has show log
2015-06-19 15:55:08.245 stun[4669:607] stun server: stunserver.org 2015-06-19 15:55:08.247 stun[4669:607] stun binding request=<00010000 2112a442 ab8b1ef9 7347bf10 e98c817b> 2015-06-19 15:55:08.275 stun[4669:607] stun didsenddatawithtag=1002
i can not show public ip need.
please give me advice solve problem. many thanks
nsstring *hostn = @"stunserver.org"; struct hostent* phot; phot = gethostbyname(hostn.utf8string); if(phot) { struct in_addr ip_addr; memcpy(&ip_addr, phot->h_addr_list[0], 4); char *ip = (char*)malloc(sizeof(char)*20); inet_ntop(af_inet, &ip_addr, ip, 20); nsstring *ipstr = [nsstring stringwithutf8string:ip]; free(ip); nslog(@"ip:%@", ipstr); }
and include head file
#include <netdb.h> #include <sys/socket.h> #include <arpa/inet.h>
Comments
Post a Comment