tcp_accept()
#include "tcp.h" int fd,Service; fd = tcp_accept(Service); if (fd == -1) ... an error occurred.
The C function tcp_accept()
is used to accept a connection
request. It returns the file descriptor for the newly created socket
(fd).
A connection request is recognized when the file descriptor returned
by the C function tcp_select()
is the file descriptor for the
passive socket returned by tcp_create_listener()
. In other words,
tcp_select()
indicates that the passive socket created by
tcp_create_listener()
has input available. Since it is impossible to read
from a passive socket, this means that a connection request is
pending, and it is time to call tcp_accept()
to accept the
connection request.