Discovering Bluetooth Devices and Services

To facilitate the discovery of Bluetooth devices and services, Windows maps the Bluetooth Service Discovery Protocol (SDP) onto the Windows Sockets namespace interfaces. The primary functions used for this mapping are the WSASetService, WSALookupServiceBegin, WSALookupServiceNext, and WSALookupServiceEnd functions. The WSAQUERYSET structure is also used in conjunction with these functions.

Because certain concepts and parameters from the Bluetooth SDP do not necessarily map directly into the WSAQUERYSET structure, attention must be paid to how its members are created and used. For many complex Bluetooth operations, such as the creation of SDP records, the lpBlob member of the WSAQUERYSET is used. When such special consideration is necessary, it is specifically described, such as in reference pages like Bluetooth and WSALookupServiceNext, and others.

It is important to understand that SDP registration is separate from socket control. When a server application is prepared to accept client connection, it should call the WSASetService function to register a Bluetooth SDP record that corresponds to that service. That Bluetooth application must call the WSASetService function again before closing, to deregister the Bluetooth SDP record.

When using the mapping functions described on this page, the NS_BTH namespace is assigned.

For further information about discovering devices and services, consult the following reference pages:

You can also download the Bluetooth connection sample for a complete example.

Bluetooth Programming with Windows Sockets

Bluetooth connection sample