Skip to content

Instantly share code, notes, and snippets.

@alsamitech
Created April 8, 2021 02:15
Show Gist options
  • Select an option

  • Save alsamitech/05ca8d384c094b56ba616e53c6072d07 to your computer and use it in GitHub Desktop.

Select an option

Save alsamitech/05ca8d384c094b56ba616e53c6072d07 to your computer and use it in GitHub Desktop.
Returns IP adress of URL
typedef struct hostent hostent_t;
typedef struct in_addr inaddr_t;
char* dns_nm_to_addr(char* nm){
hostent_t* hostinfo;
inaddr_t* addr;
hostinfo=gethostbyname(nm);
return inet_ntoa(*(inaddr_t*)(hostinfo->h_addr));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment