aboutsummaryrefslogtreecommitdiffstats
path: root/man2/select_tut.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/select_tut.2')
-rw-r--r--man2/select_tut.242
1 files changed, 21 insertions, 21 deletions
diff --git a/man2/select_tut.2 b/man2/select_tut.2
index a31832dfa1..b29f69e646 100644
--- a/man2/select_tut.2
+++ b/man2/select_tut.2
@@ -192,7 +192,7 @@ int main (int argc, char **argv) {
signal (SIGCHLD, child_sig_handler);
for (;;) { /* main loop */
- for (; child_events > 0; child_events--) {
+ for (; child_events > 0; child_events\-\-) {
/* do event work here */
}
r = pselect (nfds, &rd, &wr, &er, 0, &orig_sigmask);
@@ -260,7 +260,7 @@ main(void) {
retval = select(1, &rfds, NULL, NULL, &tv);
/* Don't rely on the value of tv now! */
- if (retval == -1)
+ if (retval == \-1)
perror("select()");
else if (retval)
printf("Data is available now.\\n");
@@ -304,7 +304,7 @@ static int listen_socket (int listen_port) {
int yes;
if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
perror ("socket");
- return -1;
+ return \-1;
}
yes = 1;
if (setsockopt
@@ -312,7 +312,7 @@ static int listen_socket (int listen_port) {
(char *) &yes, sizeof (yes)) < 0) {
perror ("setsockopt");
close (s);
- return -1;
+ return \-1;
}
memset (&a, 0, sizeof (a));
a.sin_port = htons (listen_port);
@@ -321,7 +321,7 @@ static int listen_socket (int listen_port) {
(s, (struct sockaddr *) &a, sizeof (a)) < 0) {
perror ("bind");
close (s);
- return -1;
+ return \-1;
}
printf ("accepting connections on port %d\\n",
(int) listen_port);
@@ -336,7 +336,7 @@ static int connect_socket (int connect_port,
if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
perror ("socket");
close (s);
- return -1;
+ return \-1;
}
memset (&a, 0, sizeof (a));
@@ -348,7 +348,7 @@ static int connect_socket (int connect_port,
(struct in_addr *) &a.sin_addr.s_addr)) {
perror ("bad IP address format");
close (s);
- return -1;
+ return \-1;
}
if (connect
@@ -357,7 +357,7 @@ static int connect_socket (int connect_port,
perror ("connect()");
shutdown (s, SHUT_RDWR);
close (s);
- return -1;
+ return \-1;
}
return s;
}
@@ -366,7 +366,7 @@ static int connect_socket (int connect_port,
if (fd1 >= 0) { \\
shutdown (fd1, SHUT_RDWR); \\
close (fd1); \\
- fd1 = -1; \\
+ fd1 = \-1; \\
} \\
}
@@ -374,7 +374,7 @@ static int connect_socket (int connect_port,
if (fd2 >= 0) { \\
shutdown (fd2, SHUT_RDWR); \\
close (fd2); \\
- fd2 = -1; \\
+ fd2 = \-1; \\
} \\
}
@@ -382,7 +382,7 @@ static int connect_socket (int connect_port,
int main (int argc, char **argv) {
int h;
- int fd1 = -1, fd2 = -1;
+ int fd1 = \-1, fd2 = \-1;
char buf1[BUF_SIZE], buf2[BUF_SIZE];
int buf1_avail, buf1_written;
int buf2_avail, buf2_written;
@@ -419,12 +419,12 @@ int main (int argc, char **argv) {
nfds = max (nfds, fd2);
}
if (fd1 > 0
- && buf2_avail - buf2_written > 0) {
+ && buf2_avail \- buf2_written > 0) {
FD_SET (fd1, &wr);
nfds = max (nfds, fd1);
}
if (fd2 > 0
- && buf1_avail - buf1_written > 0) {
+ && buf1_avail \- buf1_written > 0) {
FD_SET (fd2, &wr);
nfds = max (nfds, fd2);
}
@@ -439,7 +439,7 @@ int main (int argc, char **argv) {
r = select (nfds + 1, &rd, &wr, &er, NULL);
- if (r == -1 && errno == EINTR)
+ if (r == \-1 && errno == EINTR)
continue;
if (r < 0) {
perror ("select()");
@@ -496,7 +496,7 @@ int main (int argc, char **argv) {
if (FD_ISSET (fd1, &rd)) {
r =
read (fd1, buf1 + buf1_avail,
- BUF_SIZE - buf1_avail);
+ BUF_SIZE \- buf1_avail);
if (r < 1) {
SHUT_FD1;
} else
@@ -506,7 +506,7 @@ int main (int argc, char **argv) {
if (FD_ISSET (fd2, &rd)) {
r =
read (fd2, buf2 + buf2_avail,
- BUF_SIZE - buf2_avail);
+ BUF_SIZE \- buf2_avail);
if (r < 1) {
SHUT_FD2;
} else
@@ -517,7 +517,7 @@ int main (int argc, char **argv) {
r =
write (fd1,
buf2 + buf2_written,
- buf2_avail -
+ buf2_avail \-
buf2_written);
if (r < 1) {
SHUT_FD1;
@@ -529,7 +529,7 @@ int main (int argc, char **argv) {
r =
write (fd2,
buf1 + buf1_written,
- buf1_avail -
+ buf1_avail \-
buf1_written);
if (r < 1) {
SHUT_FD2;
@@ -544,11 +544,11 @@ int main (int argc, char **argv) {
/* one side has closed the connection, keep
writing to the other side until empty */
if (fd1 < 0
- && buf1_avail - buf1_written == 0) {
+ && buf1_avail \- buf1_written == 0) {
SHUT_FD2;
}
if (fd2 < 0
- && buf2_avail - buf2_written == 0) {
+ && buf2_avail \- buf2_written == 0) {
SHUT_FD1;
}
}
@@ -567,7 +567,7 @@ to have 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 - one for each connection. At the moment, new
+of buffers \(em one for each connection. At the moment, new
connections cause the current connection to be dropped.
.SH SELECT LAW