Chapter 25


Chapter 14

14.1

If no handler had been set, the return from the first call to signal would be SIG_DFL and the call to signal to reset the handler would just set it back to its default.

14.3

Here is just the for loop:

 for ( ; ; ) { if ( (n = Recv(sockfd, recvline, MAXLINE, MSG_PEEK)) == 0) break; /* server closed connection */ Ioctl(sockfd, FIONREAD, &npend); printf("%d bytes from PEEK, %d bytes pending\n", n, npend); n = Read(sockfd, recvline, MAXLINE); recvline[n] = 0; /* null terminate */ Fputs(recvline, stdout ); } 
14.4

The data is still output because falling off the end of the main function is the same as returning from this function, and the main function is called by the C startup routine as follows :

 exit(main(argc, argv)); 

Hence, exit is called, plus the standard I/O cleanup routine is called.




UNIX Network Programming Volume 1, Third Edition
Unix Network Programming, Volume 1: The Sockets Networking API (3rd Edition)
ISBN: 0131411551
EAN: 2147483647
Year: 2003
Pages: 441

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net