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 provides a set of structures that are used extensively throughout the name resolution functions.

Query-Related Data Structures

The WSAQUERYSETstructure is used to form queries for WSALookupServiceBegin, and used to deliver query results for WSALookupServiceNext. It is a complex structure because it contains pointers to several other structures, some of which reference even more structures.

Within the WSAQUERYSETstructure, most of the parameters are self explanatory, but some deserve additional explanation. The dwSizeparameter must always be completed with sizeof(WSAQUERYSET), because this is used by namespace providers to detect and adapt to different versions of the WSAQUERYSETstructure that may appear over time.

The dwOutputFlagsparameter is used by a namespace provider to provide additional information about query results. For more information, see WSALookupServiceNext.

The WSAECOMPARATORstructure referenced by lpversionis used for both query constraint and results. For queries, the dwVersionparameter indicates the desired version of the service. The ecHowparameter is an enumerated type that specifies how the comparison can be made. The choices are COMP_EQUALS, which requires that an exact match in version occur, or COMP_NOTLESS, which requires that the service's version number be no less than the value of dwVersion.

The lpszContextparameter applies to hierarchical namespaces, and specifies the starting point of a query or the location within the hierarchy where the service resides. The following general rules apply:

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

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

  • 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 namespace specific. If dwNameSpaceis NS_ALL, then only "" or "\" should be passed as the context because these are recognized by all namespaces.

The lpszQueryStringparameter is used to supply additional, namespace-specific query information such as a string describing a well-known service and transport protocol name, as in "FTP/TCP".

The AFPROTOCOLSstructure referenced by lpafpProtocolsis used for query purposes only, and supplies a list of protocols to constrain the query. These protocols are represented as address family, protocol pairs because protocol values only have meaning within the context of an address family.

The array of CSADDR_INFOstructure referenced by lpcsaBuffercontains all of the information needed for either a service to use in establishing a listen, or a client to use in establishing a connection to the service. The LocalAddrand RemoteAddrparameters both directly contain a SOCKET_ADDRESSstructure. 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.lpSockaddrLengthwhen making a remote connection.

Service Class Data Structures

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

For each service class, there is a single WSASERVICECLASSINFOstructure. Within the WSASERVICECLASSINFOstructure, the service class unique identifier is contained in lpServiceClassId, and an associated display string is referenced by lpServiceClassName. The lpClassInfosparameter in the WSASERVICECLASSINFOstructure references an array of WSANSCLASSINFOstructures, each of which supplies a named and typed parameter that applies to a specified namespace. Examples of values for the lpszNameparameter include SapId, TcpPort, UdpPort, and so on. These strings are generally specific to the namespace identified in dwNameSpace. Typical values for dwValueTypemight be REG_DWORD and REG_SZ. The dwValueSizeparameter indicates the length of the data item pointed to by lpValue.

See Also