summaryrefslogtreecommitdiffstats
path: root/man2/select_tut.2
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:41:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:41:07 +0000
commit3af6d22bb3850ab2bac67287e3a3d3b0e32868e5 (patch)
tree3ee7a3ec64525911fa865bb984c86d997d855527 /man2/select_tut.2
parentAdding debian version 6.05.01-1. (diff)
downloadmanpages-3af6d22bb3850ab2bac67287e3a3d3b0e32868e5.tar.xz
manpages-3af6d22bb3850ab2bac67287e3a3d3b0e32868e5.zip
Merging upstream version 6.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--man2/select_tut.218
1 files changed, 9 insertions, 9 deletions
diff --git a/man2/select_tut.2 b/man2/select_tut.2
index e860de3..cbb6953 100644
--- a/man2/select_tut.2
+++ b/man2/select_tut.2
@@ -9,7 +9,7 @@
.\" various other changes
.\" 2008-01-26, mtk, substantial changes and rewrites
.\"
-.TH SELECT_TUT 2 2023-05-03 "Linux man-pages 6.05.01"
+.TH SELECT_TUT 2 2023-10-31 "Linux man-pages 6.7"
.SH NAME
select, pselect \- synchronous I/O multiplexing
.SH LIBRARY
@@ -27,7 +27,7 @@ system calls are used to efficiently monitor multiple file descriptors,
to see if any of them is, or becomes, "ready";
that is, to see whether I/O becomes possible,
or an "exceptional condition" has occurred on any of the file descriptors.
-.PP
+.P
This page provides background and tutorial information
on the use of these system calls.
For details of the arguments and semantics of
@@ -54,7 +54,7 @@ This behavior is essential so that signals can be processed
in the main loop of the program, otherwise
.BR select ()
would block indefinitely.
-.PP
+.P
Now, somewhere
in the main loop will be a conditional to check the global flag.
So we must ask:
@@ -82,7 +82,7 @@ call would enable
.B SIGCHLD
by using an empty signal mask.
Our program would look like:
-.PP
+.P
.EX
static volatile sig_atomic_t got_SIGCHLD = 0;
\&
@@ -310,7 +310,7 @@ can be used to solve
many problems in a portable and efficient way that naive programmers try
to solve in a more complicated manner using
threads, forking, IPCs, signals, memory sharing, and so on.
-.PP
+.P
The
.BR poll (2)
system call has the same functionality as
@@ -319,7 +319,7 @@ and is somewhat more efficient when monitoring sparse
file descriptor sets.
It is nowadays widely available, but historically was less portable than
.BR select ().
-.PP
+.P
The Linux-specific
.BR epoll (7)
API provides an interface that is more efficient than
@@ -332,7 +332,7 @@ Here is an example that better demonstrates the true utility of
.BR select ().
The listing below is a TCP forwarding program that forwards
from one TCP port to another.
-.PP
+.P
.\" SRC BEGIN (select.c)
.EX
#include <arpa/inet.h>
@@ -604,7 +604,7 @@ main(int argc, char *argv[])
}
.EE
.\" SRC END
-.PP
+.P
The above program properly forwards most kinds of TCP connections
including OOB signal data transmitted by \fBtelnet\fP servers.
It handles the tricky problem of having data flow in both directions
@@ -617,7 +617,7 @@ Another idea is to set nonblocking I/O using
.BR fcntl (2).
This also has its problems because you end up using
inefficient timeouts.
-.PP
+.P
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.