Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

Winsock 1.1 supports a set of functions that can be used for name resolution with TCP/IP (IP version 4) networks. These are customarily called the getXbyYfunctions. The following list shows these functions:

Note:
The gethostbyname function has been deprecated by the introduction of getaddrinfo, and gethostbyaddr has been deprecated by getnameinfo.

Ws2.dll provides the following two functions that are used to convert dotted Ipv4 Internet address notation to and from string and binary representations, respectively.

All of these functions are specific to Ipv4 TCP/IP networks. If you want to develop protocol-independent applications, you should not use these transport-specific functions. However, in order to retain strict backward compatibility with Winsock 1.1, all of the preceding functions will continue to be supported as long as at least one namespace provider is present that supports the AF_INET address family (these functions are not relevant to IP version 6, denoted by AF_INET6).

Ws2.dll translates most getXbyYfunctions to a sequence of calls to the WSALookupServiceBegin (Windows Sockets), WSALookupServiceNext (Windows Sockets), and WSALookupServiceEnd (Windows Sockets)functions by using one of a set of special GUIDs as the service class. These GUIDs identify the type of getXbyYoperation that is being emulated. The query is constrained to those name space providers (NSPs) that support AF_INET.

The following table shows the service class GUIDS that are used to translate the gethostbynameand gethostbyaddrfunctions.

Function GUID Description

gethostbyname

SVCID_INET_HOSTADDRBYNAME

The host name that is specified in the lpszServiceInstanceNamemember of the WSAQUERYSET (Windows Sockets)structure.

gethostbyaddr

SVCID_INET_HOSTNAMEBYADDR

The host address as specified in the lpszServiceInstanceNamemember of WSAQUERYSETas a dotted Internet string.

To initiate a query, the NSP calls WSALookupServiceBeginby using the service class GUID. Ws2.dll specifies the LUP_RETURN_BLOB flag and the NSP places the hostentstructure in the Binary Large Object (BLOB). The hostentstructure must be modified slightly in that the pointers that are contained within it must be replaced with offsets that are relative to the start of the data for the BLOB The BLOB must contain all values that are referenced by these pointer parameters, and all strings must be ASCII.

In addition to the LUP_RETURN_BLOB flag, the NSP should also support the following LUP_RETURN_* flags.

Flag Description

LUP_RETURN_NAME

Returns the h_nameparameter from hostentstructure in lpszServiceInstanceName.

LUP_RETURN_ADDR

Returns addressing information from hostentin CSADDR_INFOstructures, port information is defaulted to zero. Note that this routine does notresolve host names that consist of a dotted Internet address.

See Also

Concepts

Winsock Name Resolution

Other Resources