Share via


socket (Bluetooth) (Windows Embedded CE 6.0)

1/6/2010

This function creates a socket that is bound to a specific service provider.

Note

This function is actually a Winsock function. However, the information that is presented in it is specific to Bluetooth.

Syntax

SOCKET socket(
  int af,
  int type,
  int protocol
);

Parameters

  • af
    [in] Address family specification. To create a Bluetooth socket, use: af = AF_BTH
  • type
    [in] Type specification for the new socket. To create a Bluetooth socket, use:

    type = 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:

    protocol = BTHPROTO_RFCOMM

Return Value

If no error occurs, this function returns a descriptor referencing the new socket. If an error occurs, a value of INVALID_SOCKET is returned, and a specific error code can be retrieved by calling WSAGetLastError.

Remarks

The following example code shows how to use socket to create a Bluetooth socket.

SOCKET s = socket (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);

For more information about the socket function, see socket (Windows Sockets) in the Winsock reference.

Requirements

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

See Also

Reference

Bluetooth Application Development Functions

Concepts

Winsock Extensions