User`s guide
200
K
A
DAK
KwikNet TCP/IP Sockets
kn_getpeername kn_getpeername
Purpose Get the Address (Name) of the Remote End of a Connected Socket
Used by
n Task o ISP o Timer Procedure o Restart Procedure o Exit Procedure
Setup Prototype is in file KN_SOCK.H.
#include "KN_SOCK.H"
int kn_getpeername(int s, struct sockaddr *destaddr,
int *addrlen);
Description S is a socket descriptor identifying the socket for which the remote end
(peer) address is desired.
Destaddr is a pointer to storage for the address of the remote end of the
current connection on socket s. The format of the IP address in
structure sockaddr is described in header file KN_SOCK.H.
Addrlen is a pointer to storage for the length of the remote address. On
entry, the integer at *addrlen must define the maximum storage
available within the structure referenced by destaddr.
Returns If successful, a value of 0 is returned.
The structure at *destaddr contains the remote end address.
The storage at *addrlen is unaltered.
On failure, the error status -1 is returned. The storage at *destaddr and
*addrlen is unaltered.
The error indicator for socket s is set to define the reason for failure. Use
kn_errno() to retrieve the error code.
EBADF The socket descriptor s is invalid.
ENOTCONN The socket is not connected.
EINVAL Parameter destaddr or addrlen is invalid or
parameter
*addrlen specifies a length that is less
than that required to accommodate a valid address.
See Also
kn_connect(), kn_getsockname(), kn_socket()