X-Git-Url: http://git.osdn.net/view?p=linuxjm%2FLDP_man-pages.git;a=blobdiff_plain;f=original%2Fman2%2Fselect_tut.2;h=6141daf9567f0ae5e4c8b45042fbaa365b666d00;hp=17c74ac9bb5d2dfefaade93d3221fdb25f61e017;hb=4ea6bb24817f6f049d6bbc90ecd77a869876f9b0;hpb=4b904a2f7904198bf8397efd8c787e1e512992a5 diff --git a/original/man2/select_tut.2 b/original/man2/select_tut.2 index 17c74ac9..6141daf9 100644 --- a/original/man2/select_tut.2 +++ b/original/man2/select_tut.2 @@ -1,5 +1,6 @@ .\" This manpage is copyright (C) 2001 Paul Sheer. .\" +.\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. @@ -19,6 +20,7 @@ .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. +.\" %%%LICENSE_END .\" .\" very minor changes, aeb .\" @@ -27,7 +29,7 @@ .\" various other changes .\" 2008-01-26, mtk, substantial changes and rewrites .\" -.TH SELECT_TUT 2 2010-06-10 "Linux" "Linux Programmer's Manual" +.TH SELECT_TUT 2 2013-12-30 "Linux" "Linux Programmer's Manual" .SH NAME select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO \- synchronous I/O multiplexing @@ -208,7 +210,7 @@ In this case, .BR pselect () will then behave just like .BR select (). -.SS Combining Signal and Data Events +.SS Combining signal and data events .BR pselect () is useful if you are waiting for a signal as well as for file descriptor(s) to become ready for I/O. @@ -238,7 +240,7 @@ This race condition is solved by the .BR pselect () call. This call can be used to set the signal mask to a set of signals -that are only to be received within the +that are to be received only within the .BR pselect () call. For instance, let us say that the event in question @@ -329,7 +331,7 @@ find that one of your calls may block waiting for data from/to a file descriptor, while another file descriptor is unused though ready for I/O. .BR select () efficiently copes with this situation. -.SS Select Law +.SS Select law Many people who try to use .BR select () come across behavior that is @@ -382,7 +384,7 @@ If they do read/write the full amount, it's because you have a low traffic load and a fast stream. This is not always going to be the case. You should cope with the case of your -functions only managing to send or receive a single byte. +functions managing to send or receive only a single byte. .TP 6. Never read/write only in single bytes at a time unless you are really @@ -464,7 +466,7 @@ then the sets must be reinitialized before each call. .\" Having no file descriptors set is a useful .\" way to sleep the process with subsecond precision by using the timeout. .\" (See further on.) -.SS Usleep Emulation +.SS Usleep emulation On systems that do not have a .BR usleep (3) function, you can call @@ -479,7 +481,7 @@ follows: select(0, NULL, NULL, NULL, &tv); .fi .PP -This is only guaranteed to work on UNIX systems, however. +This is guaranteed to work only on UNIX systems, however. .SH RETURN VALUE On success, .BR select () @@ -555,13 +557,14 @@ listen_socket(int listen_port) int s; int yes; - if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) { + s = socket(AF_INET, SOCK_STREAM, 0); + if (s == \-1) { perror("socket"); return \-1; } yes = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, - (char *) &yes, sizeof(yes)) == \-1) { + &yes, sizeof(yes)) == \-1) { perror("setsockopt"); close(s); return \-1; @@ -585,7 +588,8 @@ connect_socket(int connect_port, char *address) struct sockaddr_in a; int s; - if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) { + s = socket(AF_INET, SOCK_STREAM, 0); + if (s == \-1) { perror("socket"); close(s); return \-1; @@ -638,8 +642,8 @@ main(int argc, char *argv[]) int buf2_avail, buf2_written; if (argc != 4) { - fprintf(stderr, "Usage\\n\\tfwd " - " \\n"); + fprintf(stderr, "Usage\\n\\tfwd " + " \\n"); exit(EXIT_FAILURE); } @@ -833,3 +837,12 @@ connections cause the current connection to be dropped. .BR epoll (7) .\" .SH AUTHORS .\" This man page was written by Paul Sheer. +.SH COLOPHON +This page is part of release 3.79 of the Linux +.I man-pages +project. +A description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%http://www.kernel.org/doc/man\-pages/.