|
getpeername
The Windows Sockets getpeername function gets the address of the peer to which a socket is connected.
int getpeername (
SOCKET s,
|
| struct sockaddr FAR* name,
|
| int FAR* namelen
|
| );
|
|
Parameters
s
[in] A descriptor identifying a connected socket.
name
[out] The structure which is to receive the name of the peer.
namelen
[out] A pointer to the size of the name structure.
Remarks
getpeername retrieves the name of the peer connected to the socket s and stores it in the struct sockaddr identified by name. It 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 returned any name specified by a previous sendto call will not be returned by getpeername.
On return, the namelen argument contains the actual size of the name returned in bytes.
Return Values
If no error occurs, getpeername returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific
error code can be retrieved by calling WSAGetLastError.
Error Codes
WSANOTINITIALISED
| A successful WSAStartup must occur before using this function.
| WSAENETDOWN
| The network subsystem has failed.
| WSAEFAULT
| The name or the namelen argument is not a valid part of the user address space, or the namelen argument is too small.
| WSAEINPROGRESS
| A blocking Windows Sockets 1.1 call is in progress, or the service provider is
still processing a callback function.
| WSAENOTCONN
| The socket is not connected.
| WSAENOTSOCK
| The descriptor is not a socket.
|
See Also
bind, getsockname, socket
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
More Online Helps
Win32 Programmer's Reference (win32.hlp)
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|