Share via


getsockname (Bluetooth) (Windows Embedded CE 6.0)

1/6/2010

This function retrieves the local name for a socket.

Note

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

Syntax

int getsockname(
  SOCKET s,
  struct sockaddr FAR* name,
  int FAR* namelen
);

Parameters

  • s
    [in] Descriptor identifying a socket.
  • name
    [out] Receives the address (name) of the socket.
  • namelen
    [in, out] Size of the name buffer.

Return Value

If no error occurs, this function returns zero. If an error occurs, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

Remarks

Use getsockname to retrieve the server channel allocated to the socket by a call to bind and the Bluetooth address of local device.

The following example code shows how to use getsockname.

SOCKADDR_BTH sab;
int len = sizeof(sab);
if (0 == getsockname (s, &sab, &len)) {
  wprintf (L"Local Bluetooth device is %04x%08x, server channel = %d\n",
  GET_NAP(sab.btAddr), GET_SAP(sab.btAddr), sab.port);
}

For more information about the getsockname function, see getsockname (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