In IPv4 environment(usually) we used to call function gethostbyname() to do DNS lookups.then the information is load into a struct hostent.
#include <netdb.h>
struct hostent *gethostbyname(const char *name);
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */
};
#define h_addr h_addr_list[0] /* address, for backward compatibility */
So, the easiest way to get information from gethostbyname() call is by extracting hostent structure.
Continue reading »