User`s guide
KwikNet TCP/IP Sockets
K
A
DAK
195
kn_bind kn_bind
Purpose Bind a Local Address to 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_bind(int s, struct sockaddr *localaddr, int addrlen);
Description S is a socket descriptor identifying the socket to be bound.
Localaddr is a pointer to a structure containing the local address to which
the socket must be bound. The format of the IP address in structure
sockaddr is described in header file KN_SOCK.H.
Addrlen is the length of the address at *localaddr, measured in bytes.
Returns If successful, a value of 0 is returned.
On failure, the error status -1 is returned.
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.
EADDRINUSE The specified address is already in use.
EINVAL The socket is already bound to an address or
parameter localaddr or addrlen is invalid.
Note When a socket of type SOCK_DGRAM is bound to the address identified by
localaddr, the socket is immediately primed to receive datagrams
directed to that address from any foreign source.
See Also kn_accept(), kn_getsockname(), kn_listen(), kn_socket()