다음을 통해 공유


WSPGetPeerName (Windows CE 5.0)

Send Feedback

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

int WSPGetPeerName(SOCKET s,struct sockaddr FAR* name,LPINT namelen,LPINT lpErrno);

Parameters

  • s
    [in] Descriptor identifying a connected socket.
  • name
    [out] Pointer to the structure to receive the name of the peer.
  • namelen
    [in, out] Pointer to an integer that, on input, indicates the size of the structure pointed to by name, and on output indicates the size of the returned name.
  • lpErrno
    [out] Pointer to the error code.

Return Values

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

The following table shows the possible error codes.

Error value Description
WSAENETDOWN Network subsystem has failed.
WSAEFAULT 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.
WSAENOTCONN Socket is not connected.
WSAENOTSOCK Descriptor is not a socket.

Remarks

This 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 WSPConnect call will be returnedany name specified by a previous WSPSendTo call will not be returned by WSPGetPeerName.

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

Requirements

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

See Also

WSPBind | WSPSocket | WSPGetSockName

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.