Bluetooth and WSAQUERYSET for Service Inquiry

Bluetooth uses the WSAQUERYSET structure, with various functions, to facilitate the discovery of devices and services in the Bluetooth namespace, NS_BTH.

The WSALookupServiceBegin and WSALookupServiceNext functions use the WSAQUERYSET structure to obtain data about the service inquiry process. The following table describes how to set the member values in the WSAQUERYSET structure for this purpose.

MemberInput to WSALookupServiceBeginReturned value from WSALookupServiceNext
dwSizeMust be set to sizeof(WSAQUERYSET).sizeof(WSAQUERYSET) returned by system.
dwOutputFlagsNot used.Not used.
lpszServiceInstanceNameNot used.Display name of the service, converted as a UTF-8 encoded string from the default language encoding of the Bluetooth ServiceName SDP attribute. Returned if LUP_RETURN_NAME is specified.
lpServiceClassIdRequired. The most specific single Bluetooth UUID for the services for which the search is being conducted. For example, if this value is set to the UUID of the L2CAP protocol, it returns all services using the L2CAP protocol on the target device. If set to the UUID of a specific service, it would return only the instances of that service.Not used.
lpVersionNot used.Not used.
lpszCommentNot used.Description of the service, converted as a UTF-8 encoded string from the default language encoding of the Bluetooth ServiceDescription SDP attribute. Returned if LUP_RETURN_COMMENT is specified.
dwNameSpaceMust be NS_BTH.Returns NS_BTH.
lpNSProviderIdNot used.Not used.
lpszContextRequired. The Bluetooth Device Address with which to establish an SDP connection and query for services. This value must be a string that was converted by using the WSAAddressToString function call. If the local Bluetooth device address is provided, the local SDP database is searched.Not used.
dwNumberOfProtocolsNot used.Not used.
lpafpProtocolsNot used.Not used.
lpszQueryStringNot used.Not used.
dwNumberOfCsAddrsNot used.Indicates the number of elements in the array of CSADDR_INFO structures.
lpcsaBufferNot used.Pointer to a CSADDR_INFO structure whose LocalAddr.lpSockaddr member points to a SOCKADDR_BTH that contains the complete connectable address of the remote service, converted from the first entry of the Bluetooth ProtocolDescriptorList SDP attribute. Returned if LUP_RETURN_ADDR is specified.
lpBlobOptional. Pointer to a BTH_QUERY_SERVICE structure that contains advanced parameters to limit the results of the search. If provided, lpServiceClassId is ignored and cached queries do not succeed.
  • If a service search is performed: Pointer to a BLOB structure that returns the service handles. (BLOB.cbSize)/sizeof(ULONG) calculates the number of handles. BLOB.pBlobData is an array of ULONG values representing the service handles.
  • If an attribute or serviceAttribute search is performed: Pointer to a BLOB structure that returns the binary SDP record. BLOB.cbSize is the size of the binary SDP record. BLOB.pBlobData points to the record itself. The binary SDP record is necessary in many cases because only a limited number of SDP attributes are able to be converted to the WSAQUERYSET structure, and only default encoded UTF-8 strings are converted. Functions to assist in parsing the binary SDP record are provided in the Bluetooth Reference section.
  • Returned if LUP_RETURN_BLOB is specified.


Related topics

Bluetooth and WSAQUERYSET for Set Service
Bluetooth and WSAQUERYSET for Device Inquiry
Bluetooth and BLOB
Bluetooth and WSALookupServiceBegin
Bluetooth and WSALookupServiceNext
Bluetooth Reference
Windows Sockets



Community Additions