User`s guide

KwikNet TCP/IP Sockets
K
A
DAK
201
kn_getsockname kn_getsockname
Purpose Get the Local Address (Name) of a 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_getsockname(int s, struct sockaddr *localaddr,
int *addrlen);
Description S is a socket descriptor identifying the socket for which the local address
is desired.
Localaddr is a pointer to storage for the local address assigned to
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 local address. On
entry, the integer at *addrlen must define the maximum storage
available within the structure referenced by localaddr.
Returns If successful, a value of 0 is returned.
The structure at *localaddr contains the local address.
The storage at *addrlen is unaltered.
On failure, the error status -1 is returned. The storage at *localaddr 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.
EINVAL Parameter localaddr or addrlen is invalid or
parameter
*addrlen specifies a length that is less
than that required to accommodate a valid address.
See Also kn_bind(), kn_getpeername(), kn_socket()