UNIX Network Programming Volume 1, Third Edition [Electronic resources] : The Sockets Networking API

Addison Wesley

نسخه متنی -صفحه : 450/ 434
نمايش فراداده

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.