Asynchronous Use of a Connection
To asynchronously await connections, a process first establishes a
non-blocking endpoint bound to a service address. When the result of
poll
()
or an asynchronous notification indicates
that a connection request has arrived, the process can get the
connection request by using t_listen
(). To accept
the connection, the process uses t_accept
(). The
responding endpoint must be separately configured for asynchronous
data transfers. For more information, see the
t_listen
(3C) and
t_accept
(3C) man pages.
The following example illustrates how to request a connection asynchronously.
#include <tiuser.h> int fd; struct t_call *call; fd = /* establish a non-blocking endpoint */ call = (struct t_call *) t_alloc(fd, T_CALL, T_ADDR); /* initialize call structure */ t_connect(fd, call, call); /* connection request is now proceeding asynchronously */ /* receive indication that connection has been accepted */ t_rcvconnect(fd, &call);
The following example illustrates listening for connections asynchronously.
#include <tiuser.h> int fd, res_fd; struct t_call call; fd = /* establish non-blocking endpoint */ /*receive indication that connection request has arrived */ call = (struct t_call *) t_alloc(fd, T_CALL, T_ALL); t_listen(fd, &call); /* determine whether or not to accept connection */ res_fd = /* establish non-blocking endpoint for response */ t_accept(fd, res_fd, call);