NSPLookupServiceNext (Windows Embedded CE 6.0)

1/6/2010

This function is called after obtaining a handle from a previous call to NSPLookupServiceBegin in order to retrieve the requested service information.

The provider will pass back a WSAQUERYSET structure in the lpqsResults buffer. The client should continue to call this function until it returns WSA_E_NOMORE, indicating that all the WSAQUERYSET have been returned.

Syntax

int NSPAPI WSALookupServiceNext(
  HANDLE hLookup,
  DWORD dwControlFlags,
  LPDWORD lpdwBufferLength,
  LPWSAQUERYSET lpqsResults 
);

Parameters

  • dwControlFlags
    [in] Flags to control the next operation. Currently only LUP_FLUSHPREVIOUS is defined as a means to cope with a result set that is too large. If an application does not supply a large enough buffer, setting LUP_FLUSHPREVIOUS instructs the provider to discard the last result set, which was too large, and move to the next set for this call.
  • lpdwBufferLength
    [in, out] On input, the number of bytes contained in the buffer pointed to by lpqsResults. On output, if the function fails and the error is WSAEFAULT, then it contains the minimum number of bytes to pass for the lpqsResults to retrieve the record.
  • lpqsResults
    [out] Pointer to a block of memory that will contain one result set in a WSAQUERYSET structure on return.

Return Value

The function should return NO_ERROR (zero) if the routine succeeds. It should return SOCKET_ERROR (–1) if the routine fails and it must set the appropriate error code using SetLastError.

The following table shows the possible error codes.

Error value Description

WSA_E_NO_MORE

There is no more data available.

In Winsock, 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.

WSA_E_CANCELLED

Call to NSPLookupServiceEnd was made while this call was still processing. The call has been canceled. The data in the lpqsResults buffer is undefined.

In Winsock, conflicting error codes are defined for WSAECANCELLED (10103) and WSA_E_CANCELLED (10111).The error code WSAECANCELLED will be removed in a future version and only WSA_E_CANCELLED will remain. Name space providers should switch to using the WSA_E_CANCELLED error code as soon as possible to maintain compatibility with the widest possible range of applications.

WSAEFAULT

The lpqsResults buffer was too small to contain a WSAQUERYSET set.

WSAEINVAL

One or more parameters were invalid or missing for this provider.

WSA_INVALID_HANDLE

Specified lookup handle is invalid.

WSANO_DATA

The name was found in the database but no data matching the given restrictions was located.

WSASERVICE_NOT_FOUND

No such service is known. The service cannot be found in the specified name space.

WSA_NOT_ENOUGH_MEMORY

Not enough free memory available to perform this operation.

Remarks

The dwControlFlags specified in this function and the ones specified at the time of NSPLookupServiceBegin are treated as "restrictions" for the purpose of combination. The restrictions are combined between the ones at NSPLookupServiceBegin time and the ones at NSPLookupServiceNext time. Therefore, the flags at NSPLookupServiceNext can never increase the amount of data returned beyond what was requested at NSPLookupServiceBegin, although it is not an error to specify more or less flags. The flags specified at a given NSPLookupServiceNext apply only to that call.

The dwControlFlags LUP_FLUSHPREVIOUS and LUP_RES_SERVICE are exceptions to the combined restrictions rule because they are behavior flags instead of restriction flags. If either of these flags is used in NSPLookupServiceNext, they have their defined effect regardless of the setting of the same flags at NSPLookupServiceBegin.

For example, if LUP_RETURN_VERSION is specified at NSPLookupServiceBegin, the service provider retrieves records including the version. If LUP_RETURN_VERSION is not specified at NSPLookupServiceNext, the returned information does not include the version, even though it was available. No error is generated.

Also for example, if LUP_RETURN_BLOB is not specified at NSPLookupServiceBegin but is specified at NSPLookupServiceNext, the returned information does not include the private data. No error is generated.

The following table describes how the query results are represented in the WSAQUERYSET structure.

WSAQUERYSET member name Result interpretation

dwSize

Will be set to sizeof(WSAQUERYSET). This is used as a versioning mechanism.

dwOuputFlags

RESULT_IS_ALIAS flag indicates this is an alias result.

lpszServiceInstanceName

References the string that contains the service name.

lpServiceClassId

GUID corresponding to the service class.

lpVersion

References version number of the particular service instance.

lpszComment

Optional comment string supplied by service instance.

dwNameSpace

Name space in which the service instance was found.

lpNSProviderId

Identifies the specific name-space provider that supplied this query result.

lpszContext

Specifies the context point in a hierarchical name space at which the service is located.

dwNumberOfProtocols

Undefined for results.

lpafpProtocols

Undefined for results, all needed protocol information is in the CSADDR_INFO structures.

lpszQueryString

When dwControlFlags includes LUP_RETURN_QUERY_STRING, this member returns the unparsed remainder of the lpszServiceInstanceName specified in the original query. For example, in a name space that identifies services by hierarchical names that specify a host name and a file path within that host, the address returned might be the host address and the unparsed remainder might be the file path. If the lpszServiceInstanceName is fully parsed and LUP_RETURN_QUERY_STRING is used, this member is NULL or points to a zero-length string.

dwNumberOfCsAddrs

Indicates the number of elements in the array of CSADDR_INFO structures.

lpcsaBuffer

Pointer to an array of CSADDR_INFO structures, with one complete transport address contained within each element.

lpBlob

(Optional) Pointer to a provider-specific entity.

Requirements

Header ws2spi.h
Library Ws2.lib
Windows Embedded CE Windows CE .NET 4.0 and later

See Also

Reference

Winsock SPI Functions
WSAQUERYSET (Windows Sockets)
NSPLookupServiceBegin