mirror of https://github.com/mkerrisk/man-pages
select_tut.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
887f19e8a1
commit
f145f66700
|
@ -562,6 +562,7 @@ listen_socket(int listen_port)
|
|||
perror("socket");
|
||||
return \-1;
|
||||
}
|
||||
|
||||
yes = 1;
|
||||
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
|
||||
&yes, sizeof(yes)) == \-1) {
|
||||
|
@ -569,6 +570,7 @@ listen_socket(int listen_port)
|
|||
close(s);
|
||||
return \-1;
|
||||
}
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_port = htons(listen_port);
|
||||
addr.sin_family = AF_INET;
|
||||
|
@ -577,6 +579,7 @@ listen_socket(int listen_port)
|
|||
close(s);
|
||||
return \-1;
|
||||
}
|
||||
|
||||
printf("accepting connections on port %d\\n", listen_port);
|
||||
listen(s, 10);
|
||||
return s;
|
||||
|
@ -723,7 +726,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
/* NB: read oob data before normal reads */
|
||||
/* NB: read OOB data before normal reads */
|
||||
|
||||
if (fd1 > 0)
|
||||
if (FD_ISSET(fd1, &er)) {
|
||||
|
@ -782,14 +785,14 @@ main(int argc, char *argv[])
|
|||
buf1_written += r;
|
||||
}
|
||||
|
||||
/* check if write data has caught read data */
|
||||
/* Check if write data has caught read data */
|
||||
|
||||
if (buf1_written == buf1_avail)
|
||||
buf1_written = buf1_avail = 0;
|
||||
if (buf2_written == buf2_avail)
|
||||
buf2_written = buf2_avail = 0;
|
||||
|
||||
/* one side has closed the connection, keep
|
||||
/* One side has closed the connection, keep
|
||||
writing to the other side until empty */
|
||||
|
||||
if (fd1 < 0 && buf1_avail \- buf1_written == 0)
|
||||
|
|
Loading…
Reference in New Issue