Name Resolution Data Structures

There are several important data structures that are used extensively throughout the name resolution functions. These are described below.

Query-Related Data Structures

The WSAQUERYSET structure is used to form queries for WSALookupServiceBegin, and used to deliver query results for WSALookupServiceNext. It is a complex structure since it contains pointers to several other structures, some of which reference still other structures. The relationship between WSAQUERYSET and the structures it references is illustrated as follows:


Within the WSAQUERYSET structure, most of the fields are self explanatory, but some deserve additional explanation. The dwSize field must always be filled in with sizeof(WSAQUERYSET), as this is used by name space providers to detect and adapt to different versions of the WSAQUERYSET structure that may appear over time.

The dwOutputFlags field is used by a name space provider to provide additional information about query results. For details, see WSALookupServiceNext.

The WSAECOMPARATOR structure referenced by lpversion is used for both query constraint and results. For queries, the dwVersion field indicates the desired version of the service. The ecHow field is an enumerated type which specifies how the comparison will be made. The choices are COMP_EQUALS which requires that an exact match in version occurs, or COMP_NOTLESS which specifies that the service's version number be no less than the value of dwVersion.

The interpretation of dwNameSpace and lpNSProviderId depends upon how the structure is being used and is described further in the individual function descriptions that utilize this structure.

The lpszContext field applies to hierarchical name spaces, and specifies the starting point of a query or the location within the hierarchy where the service resides. The general rules are:

  • A value of NULL, blank ("") will start the search at the default context.

  • A value of "\" starts the search at the top of the name space.

  • Any other value starts the search at the designated point.

Providers that do not support containment may return an error if anything other than "" or "\" is specified. Providers that support limited containment, such as groups, should accept "", '\", or a designated point. Contexts are name space specific. If dwNameSpace is NS_ALL, then only "" or "\" should be passed as the context since these are recognized by all name spaces.

The lpszQueryString field is used to supply additional, name space-specific query information such as a string describing a well-known service and transport protocol name, as in "ftp/tcp".

The AFPROTOCOLS structure referenced by lpafpProtocols is used for query purposes only, and supplies a list of protocols to constrain the query. These protocols are represented as (address family, protocol) pairs, since protocol values only have meaning within the context of an address family.

The array of CSADDR_INFO structure referenced by lpcsaBuffer contain all of the information needed to for either a service to use in establishing a listen, or a client to use in establishing a connection to the service. The LocalAddr and RemoteAddr fields both directly contain a SOCKET_ADDRESS structure. A service would create a socket using the tuple (LocalAddr.lpSockaddr->sa_family, iSocketType, iProtocol). It would bind the socket to a local address using LocalAddr.lpSockaddr, and LocalAddr.lpSockaddrLength. The client creates its socket with the tuple (RemoteAddr.lpSockaddr->sa_family, iSocketType, iProtocol), and uses the combination of RemoteAddr.lpSockaddr, and RemoteAddr.lpSockaddrLength when making a remote connection.

Service Class Data Structures

When a new service class is installed, a WSASERVICECLASSINFO structure must be prepared and supplied. This structure also consists of substructures which contain a series of parameters that apply to specific name spaces.

Class Info Data Structures

For each service class, there is a single WSASERVICECLASSINFO structure. Within the WSASERVICECLASSINFO structure, the service class' unique identifier is contained in lpServiceClassId, and an associated display string is referenced by lpServiceClassName. This is the string that will be returned by WSAGetServiceClassNameByServiceClassId.

The lpClassInfos field in the WSASERVICECLASSINFO structure references an array of WSANSCLASSINFO structures, each of which supplies a named and typed parameter that applies to a specified name space. Examples of values for the lpszName field include: "SapId", "TcpPort", "UdpPort", etc. These strings are generally specific to the name space identified in dwNameSpace. Typical values for dwValueType might be REG_DWORD, REG_SZ, etc. The dwValueSize field indicates the length of the data item pointed to by lpValue.

The entire collection of data represented in a WSASERVICECLASSINFO structure is provided to each name space provider when WSAInstallServiceClass is invoked. Each individual name space provider then sifts through the list of WSANSCLASSINFO structures and retain the information applicable to it.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples