Partager via


getpeername (Bluetooth) (Windows Embedded CE 6.0)

1/6/2010

This function retrieves the name of the peer to which a socket is connected.

Note

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

Syntax

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

Parameters

  • s
    [in] Descriptor identifying a connected socket.
  • name
    [out] Structure that receives the name of the peer.
  • namelen
    [in, out] Pointer to the size of the name structure.

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 getpeername on a connected socket to retrieve the Bluetooth address of the peer Bluetooth device.

The following example code shows how to use getpeername.

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

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