Asynchronous Execution Mode
Many XTI/TLI library routines block to wait for an incoming event. However, some time-critical applications should not block for any reason. An application can do local processing while waiting for some asynchronous XTI/TLI event.
Applications can access asynchronous processing of XTI/TLI
events through the combination of asynchronous features and the
non-blocking mode of XTI/TLI library routines. See the
ONC+ RPC Developer’s Guide for information about use of the
poll()
system call and the
I_SETSIG
ioctl()
ioctl(2) command to process events asynchronously.
You can run each XTI/TLI routine that blocks for an event in a special
non-blocking mode. For example, t_listen()
normally blocks for a
connect request. A server can periodically poll a transport endpoint for queued connect
requests by calling t_listen()
in the non-blocking (or asynchronous)
mode. For more information, see the
t_listen(3C) man page. You enable the asynchronous mode by setting
O_NDELAY or O_NONBLOCK in the file descriptor.
Set these modes as a flag through t_open(), or by calling
fcntl()
before calling the XTI/TLI routine. Use
fcntl()
to enable or disable this mode at any time. All program
examples in this chapter use the default synchronous processing mode. For more
information, see the
t_open(3C) and
fcntl(2) man pages.
Use of O_NDELAY or O_NONBLOCK affects each XTI/TLI routine differently. You need to determine
the exact semantics of O_NDELAY or O_NONBLOCK for a particular routine.