Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/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 getpeernameon a connected socket to retrieve the Bluetooth address of the peer Bluetooth device.

The following example code shows how to use getpeername.

Copy Code
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 getpeernamefunction, 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
Windows Mobile Windows Mobile Version 5.0 and later

See Also

500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@systemmanager.forsenergy.ru to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.