objective c - Determining IP Address from URL in iOS -
i need ip address of cdn it's url in ios app. long stack search, i've determined method doing following:
struct hostent *host_entry = gethostbyname("stackoverflow.com"); char *buff; buff = inet_ntoa(*((struct in_addr *)host_entry->h_addr_list[0])); // buff equal ip of stackoverflow.com server
however, when using code snippet, app fails compile , presents warning: "dereferencing pointer incomplete type"
i have no knowledge of structs , not know how fix this. suggestions?
i tried:
#include <ifaddrs.h> #include <arpa/inet.h>
but result same warning.
i had no problems compiling code following includes:
#import <netdb.h> #include <arpa/inet.h>
Comments
Post a Comment