User`s guide
KwikNet TCP/IP Sockets
K
A
DAK
193
kn_accept kn_accept
Purpose Accept a Connection Request
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_accept(int s, struct sockaddr *addr, int *addrlen);
Description S is a socket descriptor identifying the socket on which to wait. The
socket s must have been created with a call to kn_socket(), bound to
an address with a call to kn_bind() and then made ready to receive
connection requests with a call to kn_listen().
Addr is a pointer to storage for the address of the client making the request
for connection. 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 client address. On
entry, the integer at *addrlen must define the maximum storage
available within the structure referenced by addr.
If a request for connection is pending at socket s, kn_accept() creates
a new socket with the same properties as socket s and returns the
socket descriptor of the new socket to the caller. The new socket must
be used for data transfers to or from the client to which the new socket
is connected. The new socket cannot be used to accept more
connections.
In most cases, the kn_accept() caller will be forced to wait for a
connection request if none is pending at the time of the call. However,
if the socket s was marked as non-blocking, kn_accept() will return
immediately to the caller with an error indication if an outstanding
connection request is not present. Socket
s remains open listening for
connection requests.
Returns If successful, a non-negative socket descriptor is returned.
The structure at *addr contains the client's address.
The length of the address (in bytes) is stored at *addrlen.
On failure, the error status
-1 is returned. The storage at *addr and
*addrlen is unaltered.
...more