#include <sys/types.h>
#include <tiuser.h>
#include <signal.h>
#include <stropts.h>
 
int fd;
struct t_bind *bind;
void sigpoll(int);
        ...
        fd = t_open(protocol, O_RDWR, (struct t_info *) NULL);
        bind = (struct t_bind *) t_alloc(fd, T_BIND, T_ADDR);
        ...     /* set up binding address */
        t_bind(fd, bind, bind);
        /* make endpoint non-blocking */
        fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
        /* establish signal handler for SIGPOLL */
        signal(SIGPOLL, sigpoll);
        /* request SIGPOLL signal when receive data is available */
        ioctl(fd, I_SETSIG, S_INPUT | S_HIPRI);
        ...
void 		sigpoll(int sig)
{
        int 				flags:
        struct 	t_unitdata       ud;
 
        for (;;) {
			... /* initialize ud */
			if (t_rcvudata(fd, ud, &flags) < 0) {
				if (t_error == TNODATA)
				break;  /* no more messages */
			... /* process other error conditions */
			}
		... /* process message in ud */
		}
}
