These functions provide support for implementing TCP servers.
creates a new TCP server listening for connections on IP address
Memory for the
is dynamically allocated with
simultaneous connections will be allowed.
is non-zero, then if an attempt to read from or write to a peer blocks
for more than
seconds, the connection will be terminated.
event context used to listen for incoming connections.
arguments are pointers to functions having these types:
typedef void *tcp_setup_t(struct tcp_connection *conn);
typedef void tcp_handler_t(struct tcp_connection *conn);
typedef void tcp_teardown_t(struct tcp_connection *conn);
Each connection is represented by a
For each new connection,
is called to initialize user state for the connection.
If setup is unsuccessful,
appropriately, and the connection will be closed.
Otherwise, it should return a non-NULL cookie; this cookie can be
accessed later in
is used to service the connection.
The thread calling this function may be canceled at any cancellation point;
may need to register cleanup hooks to clean up allocated resources should
is called when
returns, or the thread is canceled.
is guaranteed to be called exactly once.
stops and destroys a
All existing connection threads are canceled and the current thread
has been called for each connection.
retrieves the peers address.
object associated with the connection
returns the TCP socket associated with the connection.
returns a stream opened on top of the socket for use with stream based I/O.
The user code should
close either the socket or the stream; these will be closed automatically
when the connection is terminated.