LPWSPGETPEERNAME callback function (ws2spi.h)

The LPWSPGetPeerName function gets the address of the peer to which a socket is connected.

Syntax

LPWSPGETPEERNAME Lpwspgetpeername;

int Lpwspgetpeername(
  [in]      SOCKET s,
  [out]     sockaddr *name,
  [in, out] LPINT namelen,
  [out]     LPINT lpErrno
)
{...}

Parameters

[in] s

Descriptor identifying a connected socket.

[out] name

Pointer to the sockaddr structure to receive the name of the peer.

[in, out] namelen

On input, pointer to an integer that indicates the size of the structure pointed to by name, in bytes. On output, indicates the size of the returned name, in bytes.

[out] lpErrno

Pointer to the error code.

Return value

If no error occurs, LPWSPGetPeerName returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code is available in lpErrno.

Error Code Meaning
WSAENETDOWN
The network subsystem has failed.
WSAEFAULT
The name or the namelen parameter is not a valid part of the user address space, or the namelen parameter is too small.
WSAEINPROGRESS
Function is invoked when a callback is in progress.
WSAENOTSOCK
The descriptor is not a socket.
WSAENOTCONN
Socket is not connected.
WSAENOTSOCK
The descriptor is not a socket.

Remarks

The LPWSPGetPeerName function supplies the name of the peer connected to the socket s and stores it in the structure sockaddr referenced by name. It can be used only on a connected socket. For datagram sockets, only the name of a peer specified in a previous LPWSPConnect call will be returned and any name specified by a previous LPWSPSendTo call will not be returned by LPWSPGetPeerName.

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

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Header ws2spi.h

See also

LPWSPBind

LPWSPGetSockName

LPWSPSocket