Platform SDK: Windows Sockets

Service Query

A name service query involves a series of calls: NSPLookupServiceBegin, followed by one or more calls to NSPLookupServiceNext and ending with a call to NSPLookupServiceEnd. NSPLookupServiceBegin takes a WSAQUERYSET structure as input in order to define the query parameters along with a set of flags to provide additional control over the search operation. It returns a query handle which is used in the subsequent calls to NSPLookupServiceNext and NSPLookupServiceEnd.

The name space SPI client invokes NSPLookupServiceNext to obtain query results, with results supplied in an client-supplied WSAQUERYSET buffer. The client continues to call NSPLookupServiceNext until the error code WSA_E_NO_MORE is returned indicating that all results have been retrieved. The search is then terminated by a call to NSPLookupServiceEnd. The NSPLookupServiceEnd function can also be used to cancel a currently pending NSPLookupServiceNext when called from another thread.

In Windows Sockets 2, conflicting error codes are defined for WSAENOMORE (10102) and WSA_E_NO_MORE (10110). The error code WSAENOMORE will be removed in a future version and only WSA_E_NO_MORE will remain. Name space providers should switch to using the WSA_E_NO_MORE error code as soon as possible to maintain compatibility with the widest possible range of applications.