Compatible Name Resolution for TCP/IP in the Windows Sockets 1.1 API (Windows Embedded CE 6.0)
1/6/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 getXbyY functions. 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 getXbyY functions 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 getXbyY operation 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 gethostbyname and gethostbyaddr functions.
Function | GUID | Description |
---|---|---|
gethostbyname |
SVCID_INET_HOSTADDRBYNAME |
The host name that is specified in the lpszServiceInstanceName member 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 WSALookupServiceBegin by using the service class GUID. Ws2.dll specifies the LUP_RETURN_BLOB flag and the NSP places the hostent structure in the Binary Large Object (BLOB). The hostent structure 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_name parameter from hostent structure in lpszServiceInstanceName. |
LUP_RETURN_ADDR |
Returns addressing information from hostent in CSADDR_INFO structures, port information is defaulted to zero. Note that this routine does not resolve host names that consist of a dotted Internet address. |
See Also
Tasks
How to Convert an Application from IPv4 to IPv4/IPv6
Concepts
Backward Compatibility for Windows Sockets 1.1 Applications
Winsock Name Resolution