Compartir a través de


getpeername (Bluetooth) (Windows CE 5.0)

Send Feedback

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.

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 Values

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

OS Versions: Windows CE .NET 4.0 and later.
Header: Winsock2.h.
Link Library: Ws2.lib.

See Also

Bluetooth Application Development Functions | Winsock Extensions

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.