Share via


getpeername

This function gets the peer address to which a socket is connected.

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

Parameters

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

Return Values

Zero indicates no error occurred. SOCKET_ERROR indicates failure. To get a specific error value, call WSAGetLastError.

Remarks

The getpeername function retrieves the peer name connected to the socket s and stores it in the a SOCKADDR structure identified by name. The getpeername function can be used only on a connected socket. For datagram sockets, only the name of a peer specified in a previous connect call will be returnedany name specified by a previous sendto call will not be returned by getpeername.

On call, the namelen argument contains the name buffer size, in bytes. On return, the namelen parameter contains the actual size, in bytes, of the name returned.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winsock.h    

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

bind, getsockname, socket

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.