gethostbyname (Repost Sorry)

2003-07-30 02:36:20 AM
Format was messed up so I reposted.
After making a call to gethostbyname defined in winsock2.h it returns a
pointer to a hostent structure.
I have serveral questions dealing with this structure.
typedef struct hostent
char FAR* h_name;
char FAR FAR** h_aliases;
short h_addrtype;
short h_length;
char FAR FAR** h_addr_list;
} hostent;
h_name: Official name of the host (PC). If using the DNS or similar
system, it is the Fully Qualified Domain Name (FQDN) that caused the server
to return a reply. If using a local hosts file, it is the first entry after
the IP address.
h_aliases: Null-terminated array of alternate names.
?How do I now the size of this array. That is how many aliasses are there?
For example h_aliases[0] should be valid but is h_aliases[1] valid?
h_addrtype: Type of address being returned.
?What does this mean. On my machine I always get 2 for h_addrtype.
h_length: Length of each address, in bytes.
?On my machine this is always 4 bytes.? Can it ever be anything else?
h_addr_list: Null-terminated list of addresses for the host. Addresses are
returned in
network byte order. The macro h_addr is defined to be h_addr_list[0] for
compatibility with older software.
? Again how do I know the size of this array?
? How do I get the actual ip addresses from this structure in the format of etc. It says the addresses are 4 bytes (refer back to h_length)
but I need to convert them to string.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.502 / Virus Database: 300 - Release Date: 7/18/2003