1 #include	"unpxti.h"
2 
3 int		listenfd, connfd;
4 
5 void
sig_poll(int signo)6 sig_poll(int signo)
7 {
8 	int		n, flags;
9 	char	buff[MAXLINE];
10 
11 	printf("SIGPOLL, event = %d\n", t_look(connfd));
12 	n = T_rcv(connfd, buff, sizeof(buff), &flags);
13 	printf("received %d bytes, flags = %d\n", n, flags);
14 }
15 
16 int
main(int argc,char ** argv)17 main(int argc, char **argv)
18 {
19 	if (argc == 2)
20 		listenfd = Tcp_listen(NULL, argv[1], NULL);
21 	else if (argc == 3)
22 		listenfd = Tcp_listen(argv[1], argv[2], NULL);
23 	else
24 		err_quit("usage: test05 [ <host> ] <service or port>");
25 
26 	connfd = Xti_accept(listenfd, NULL, 0);
27 
28 	Signal(SIGPOLL, sig_poll);
29 	Ioctl(connfd, I_SETSIG, S_RDNORM);
30 
31 	for ( ; ; ) {
32 		pause();
33 	}
34 }
35