socket (Bluetooth) (Compact 2013)
3/26/2014
This function creates a socket that is bound to a specific service provider.
Syntax
SOCKET socket(
int af,
int type,
int protocol
);
Parameters
- af
[in] Address family specification. To create a Bluetooth socket, use AF_BTH.
- type
[in] Type specification for the new socket. To create a Bluetooth socket, use SOCK_STREAM.
- protocol
[in] Protocol to be used with the socket that is specific to the indicated address family. To create a Bluetooth socket, use BTHPROTO_RFCOMM.
Return Value
Returns a handle to the new socket on success; otherwise returns INVALID_SOCKET. The specific error code can be retrieved by calling WSAGetLastError.
Remarks
Note
This function is actually a Winsock function. However, the information that is presented in it is specific to Bluetooth.
For more information about the socket function, see socket (Windows Sockets) in the Winsock reference.
Example
The following example code shows how to use socket to create a Bluetooth socket.
SOCKET s = socket (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
Requirements
Header |
winsock2.h |
Library |
Ws2.lib |
See Also
Reference
Bluetooth API Miscellaneous Functions
Bluetooth API Management Functions