I've written a program to download the video streamed from different sites to my computer,
everything works fine with youtube or other sites but when I try to get the IP of Metacafe, inet_ntop() returns NULL.
this is the code I'm using: (address will be stored in ip)
any idea why this is happening?
everything works fine with youtube or other sites but when I try to get the IP of Metacafe, inet_ntop() returns NULL.
this is the code I'm using: (address will be stored in ip)
Code:
struct hostent *hent;
size_t iplen = 15; //XXX.XXX.XXX.XXX
char *ip = (char *)malloc(iplen+1); //this is our address
memset(ip, 0, iplen+1);
if((hent = gethostbyname(host)) == NULL)
{
herror("Can't get IP");
exit(1);
}
if(inet_ntop(AF_INET, (const void *)hent->h_addr_list[0], ip, iplen) == NULL)
{
perror("Can't resolve Host");
exit(1);
}