User`s guide

204
K
A
DAK
KwikNet TCP/IP Sockets
kn_listen kn_listen
Purpose Request a Socket to Listen for Connection Requests
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_listen(int s, int backlog);
Description S is a socket descriptor identifying the socket on which requests for
connection will be enqueued. The socket s must have been created
with a call to kn_socket() and bound to an address with a call to
kn_bind(). The socket must be of type SOCK_STREAM.
Backlog is the maximum number of pending connection requests which
the socket is permitted to queue. Backlog must be greater than or
equal to 0 and no greater than the maximum allowed by your KwikNet
Library configuration.
Any request for a connection to the socket will be permitted up to the
maximum specified by backlog. Requests are kept in a queue in the
order received. When the application calls kn_accept(), it is given a
new socket connected to the client from whom the connection request
was received.
If a request for connection is received while the socket queue is full, the
request is rejected. Subsequent actions, if any, will be determined by
the client whose request was rejected.
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.
EINVAL The connection queue specified by backlog is <0.
EOPNOTSUPP The operation is not supported by a socket unless the
socket is of type
SOCK_STREAM.
See Also kn_accept(), kn_bind(), kn_socket()