gethostbyaddr (Windows Embedded CE 6.0)
1/6/2010
This function retrieves the host information corresponding to a network address.
Note
The gethostbyaddr function has been deprecated by the introduction of the getnameinfo function. Developers who create Windows Sockets 2 applications are urged to use the getnameinfo function instead of the gethostbyaddr function. See Remarks.
Syntax
struct hostent FAR* gethostbyaddr(
const char FAR* addr,
int len,
int type
);
Parameters
- addr
[in] Pointer to an address in network byte order.
- len
[in] Length of the address.
- type
[in] Type of the address, such as the AF_INET address family type (defined as TCP, UDP, and other associated Internet protocols). Address family types and their corresponding values are defined in the winsock2.h header file.
Return Value
If no error occurs, this function returns a pointer to the hostent structure that contains the name and address corresponding to the given network address. If an error occurs, it returns a NULL pointer, and a specific error code can be retrieved by calling WSAGetLastError.
The following table shows a list of possible error codes.
Error code | Description |
---|---|
WSANOTINITIALISED |
A successful WSAStartup call must occur before using this function. |
WSAENETDOWN |
The network subsystem has failed. |
WSAHOST_NOT_FOUND |
An authoritative answer host was not found. |
WSATRY_AGAIN |
A nonauthoritative host was not found, or the server failed. |
WSANO_RECOVERY |
A nonrecoverable error occurred. |
WSANO_DATA |
A valid name exists, but no data record of the requested type exists. |
WSAEINPROGRESS |
A blocking Winsock 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 |
The socket was closed. |
Remarks
Although gethostbyaddr is deprecated by the getnameinfo function, gethostbyaddr is capable of returning a NetBIOS name; getnameinfo is not. Developers who require NetBIOS name resolution may need to use gethostbyaddr until their applications are completely independent of NetBIOS names.
Note
The capability to perform reverse lookups by using the gethostbyaddr function is convenient, but such lookups are considered inherently unreliable, and should be used only as a hint.
Requirements
Header | winsock2.h |
Library | Ws2.lib |
Windows Embedded CE | Windows CE 1.0 and later |
See Also
Reference
gethostbyname
hostent
WSAGetLastError
WSAStartup