gethostbyaddr (deprecated) (Compact 2013)

3/26/2014

This function retrieves the host information corresponding to a network address.

Ee495081.note(en-us,WinEmbedded.80).gifNote:
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.


struct hostent FAR* gethostbyaddr(
  const char FAR* addr,
  int len,
  int type
);

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.

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.

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.

Ee495081.note(en-us,WinEmbedded.80).gifNote:
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.

Header

winsock2.h

Library

Ws2.lib

Show: