OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / select_tut.2
index cf5319a..6141daf 100644 (file)
@@ -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
@@ -136,7 +138,7 @@ and
 for more details about OOB data.
 (One other less common case where
 .BR select (2)
-indicates an exceptional condition occurs with pseudo-terminals
+indicates an exceptional condition occurs with pseudoterminals
 in packet mode; see
 .BR tty_ioctl (4).)
 After
@@ -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
@@ -317,7 +319,7 @@ The point of
 is that it watches
 multiple descriptors at the same time and properly puts the process to
 sleep if there is no activity.
-Unix programmers often find
+UNIX programmers often find
 themselves in a position where they have to handle I/O from more than one
 file descriptor where the data flow may be intermittent.
 If you were to merely create a sequence of
@@ -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 <listen-port> "
-                 "<forward-to-port> <forward-to-ip-address>\\n");
+        fprintf(stderr, "Usage\\n\\tfwd <listen\-port> "
+                 "<forward\-to\-port> <forward\-to\-ip\-address>\\n");
         exit(EXIT_FAILURE);
     }
 
@@ -811,7 +815,7 @@ inefficient timeouts.
 
 The program does not handle more than one simultaneous connection at a
 time, although it could easily be extended to do this with a linked list
-of buffers \(em one for each connection.
+of buffers\(emone for each connection.
 At the moment, new
 connections cause the current connection to be dropped.
 .SH SEE ALSO
@@ -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/.