Click to Rate and Give Feedback
MSDN
MSDN Library
Networking
Network Protocols
Windows Sockets 2
Winsock Reference
Winsock Functions
 WSALookupServiceNext Function
WSALookupServiceNext Function

The WSALookupServiceNext function is called after obtaining a handle from a previous call to WSALookupServiceBegin 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_NO_MORE, indicating that all of WSAQUERYSET has been returned.

Syntax

C++
INT WSALookupServiceNext(
  __in     HANDLE hLookup,
  __in     DWORD dwControlFlags,
  __inout  LPDWORD lpdwBufferLength,
  __out    LPWSAQUERYSET lpqsResults
);

Parameters

hLookup [in]

Handle returned from the previous call to WSALookupServiceBegin.

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 (or cannot) supply a large enough buffer, setting LUP_FLUSHPREVIOUS instructs the provider to discard the last result set—which was too large—and move on 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, which will contain one result set in a WSAQUERYSET structure on return.

Return Value

The return value is zero if the operation was successful. Otherwise, the value SOCKET_ERROR is returned, and a specific error number can be retrieved by calling WSAGetLastError.

Error codeMeaning
WSA_E_CANCELLED

A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled. The data in the lpqsResults buffer is undefined. In Windows Sockets version 2, 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. For Windows Sockets version 2, however, applications should check for both WSAECANCELLED and WSA_E_CANCELLED for the widest possible compatibility with namespace providers that use either one.

WSA_E_NO_MORE

There is no more data available. In Windows Sockets version 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. For Windows Sockets version 2, however, applications should check for both WSAENOMORE and WSA_E_NO_MORE for the widest possible compatibility with name-space providers that use either one.

WSAEFAULT

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

WSAEINVAL

One or more required parameters were invalid or missing.

WSA_INVALID_HANDLE

The specified Lookup handle is invalid.

WSANOTINITIALISED

The WS2_32.DLL has not been initialized. The application must first call WSAStartup before calling any Windows Sockets functions.

WSANO_DATA

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

WSA_NOT_ENOUGH_MEMORY

There was insufficient memory to perform the operation.

 

Remarks

The dwControlFlags parameter specified in this function and the ones specified at the time of WSALookupServiceBegin are treated as restrictions for the purpose of combination. The restrictions are combined between the ones at WSALookupServiceBegin time and the ones at WSALookupServiceNext time. Therefore the flags at WSALookupServiceNext can never increase the amount of data returned beyond what was requested at WSALookupServiceBegin, although it is not an error to specify more or fewer flags. The flags specified at a given WSALookupServiceNext 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 are used in WSALookupServiceNext they have their defined effect regardless of the setting of the same flags at WSALookupServiceBegin.

For example, if LUP_RETURN_VERSION is specified at WSALookupServiceBegin the service provider retrieves records including the version. If LUP_RETURN_VERSION is NOT specified at WSALookupServiceNext, 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 WSALookupServiceBegin but is specified at WSALookupServiceNext, the returned information does not include the private data. No error is generated.

Query Results

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

WSAQUERYSET memberResult interpretation
dwSizeWill be set to sizeof( WSAQUERYSET). This is used as a versioning mechanism.
dwOutputFlagsRESULT_IS_ALIAS flag indicates this is an alias result.
lpszServiceInstanceNameReferenced string contains service name.
lpServiceClassIdThe GUID corresponding to the service class.
lpVersionReferences version number of the particular service instance.
lpszCommentOptional comment string specified by service instance.
dwNameSpaceNamespace in which the service instance was found.
lpNSProviderIdIdentifies the specific namespace provider that supplied this query result.
lpszContextSpecifies the context point in a hierarchical namespace at which the service is located.
dwNumberOfProtocolsUndefined for results.
lpafpProtocolsUndefined for results, all needed protocol information is in the CSADDR_INFO structures.
lpszQueryStringWhen dwControlFlags includes LUP_RETURN_QUERY_STRING, this parameter returns the unparsed remainder of the lpszServiceInstanceName specified in the original query. For example, in a namespace 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 parameter is NULL or points to a zero-length string.
dwNumberOfCsAddrsIndicates the number of elements in the array of CSADDR_INFO structures.
lpcsaBufferA pointer to an array of CSADDR_INFO structures, with one complete transport address contained within each element.
lpBlob(Optional) This is a pointer to a provider-specific entity.

 

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinsock2.h
LibraryWs2_32.lib
DLLWs2_32.dll
Unicode and ANSI namesWSALookupServiceNextW (Unicode) and WSALookupServiceNextA (ANSI)

See Also

Bluetooth and WSALookupServiceNext
Winsock Reference
Winsock Functions
WSALookupServiceBegin
WSALookupServiceEnd

Send comments about this topic to Microsoft

Build date: 11/12/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker