Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CAsyncSocket::GetPeerName

CAsyncSocket::GetPeerName 

Call this member function to get the address of the peer socket to which this socket is connected.


BOOL GetPeerName(
   CString& rPeerAddress,
   UINT& rPeerPort 
);
BOOL GetPeerName(
   SOCKADDR* lpSockAddr,
   int* lpSockAddrLen 
);

Parameters

rPeerAddress

Reference to a CString object that receives a dotted number IP address.

rPeerPort

Reference to a UINT that stores a port.

lpSockAddr

A pointer to the SOCKADDR structure that receives the name of the peer socket.

lpSockAddrLen

A pointer to the length of the address in lpSockAddr in bytes. On return, the lpSockAddrLen argument contains the actual size of lpSockAddr returned in bytes.

Nonzero if the function is successful; otherwise 0, and a specific error code can be retrieved by calling GetLastError. The following errors apply to this member function:

  • WSANOTINITIALISED   A successful AfxSocketInit must occur before using this API.

  • WSAENETDOWN   The Windows Sockets implementation detected that the network subsystem failed.

  • WSAEFAULT   The lpSockAddrLen argument is not large enough.

  • WSAEINPROGRESS   A blocking Windows Sockets call is in progress.

  • WSAENOTCONN   The socket is not connected.

  • WSAENOTSOCK   The descriptor is not a socket.

To handle IPv6 addresses, use CAsyncSocket::GetPeerNameEx.

Community Additions

ADD
Show:
© 2015 Microsoft