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
);
The gethostbyaddr function returns a pointer to the HOSTENT structure that contains the name and address corresponding to the given network address. All strings are null-terminated.
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.
WSANOTINITIALISED | A successful WSAStartup must occur before using this function. |
WSAENETDOWN | The network subsystem has failed. |
WSAHOST_NOT_FOUND | Authoritative Answer Host not found. |
WSATRY_AGAIN | Non-Authoritative Host not found, or server failed. |
WSANO_RECOVERY | Nonrecoverable error occurred. |
WSANO_DATA | Valid name, no data record of requested type. |
WSAEINPROGRESS | A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. |
WSAEAFNOSUPPORT | The type specified is not supported by the Windows Sockets implementation. |
WSAEFAULT | The addr parameter is not a valid part of the user address space, or the len parameter is too small. |
WSAEINTR | A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall. |
Windows NT: Yes
Windows: Yes
Windows CE: Use version 1.0 and later.
Header: Declared in winsock2.h.
Import Library: Link with ws2_32.lib.
gethostbyname, HOSTENT, WSAAsyncGetHostByAddr