gethostbyaddr

This 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] 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 Values

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.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winsock2.h.
Link Library: Ws2.lib.

See Also

gethostbyname | hostent | WSAGetLastError | WSAStartup

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.