gethostbyaddr
The Windows Sockets gethostbyaddr function retrieves the host information corresponding to a network address.
struct HOSTENT FAR * gethostbyaddr(
const char FAR *addr,
int len,
int type
);
Parameters
addr
[in] A pointer to an address in network byte order.
len
[in] The length of the address.
type
[in] The type of the address.
Return Values
If no error occurs, gethostbyaddr returns a pointer to the HOSTENT structure. Otherwise, it returns a NULL pointer, and a specific error code can be retrieved by calling WSAGetLastError.
HOSTENT
Windows Sockets allocates the HOSTENT structure. An application should never attempt to modify this structure or to free any of its components. Furthermore, only one copy of this structure is allocated per thread, and so the application should copy any information that it needs before issuing any other Windows Sockets API calls.
struct hostent {
char FAR * h_name;
char FAR * FAR * h_aliases;
short h_addrtype;
short h_length;
char FAR * FAR * h_addr_list;
};
Members
h_name
Official name of the host (PC).If using the DNS or similar resolution 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
A NULL-terminated array of alternate names.
h_addrtype
The type of address being returned.
h_length
The length, in bytes, of each address.
h_addr_list
A 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.