summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTycho Andersen <tycho@tycho.pizza>2022-11-28 13:58:37 -0700
committerAlejandro Colomar <alx@kernel.org>2022-12-09 21:33:59 +0100
commit3d4a283930af180c3fa2543967ebf363c093736a (patch)
tree1ed8f9d32231814e44161c66a9e1c26049fad505
parentcf5fc5c56ea13b29ff6d5a99edbf5d430478ad0e (diff)
socket.7: be explicit that connect(2) respects SO_*TIMEO
Our group recently had some confusion around this. Although f327722042df ("socket.7: Explain effect of SO_SNDTIMEO for connect()") adds a mention of connect(2), the wording around "Timeouts only have effect for system calls that perform socket I/O" is slightly confusing: is connect(2) I/O?. Let's just add connect(2) to the list of things that time out explicitly to avoid any confusion. Test program for grins: #include <stdio.h> #include <sys/socket.h> #include <netinet/ip.h> #include <arpa/inet.h> int main(void) { struct sockaddr_in servaddr = { /* tycho.pizza */ .sin_addr.s_addr = inet_addr("192.241.255.151"), .sin_port = htons(443), .sin_family = AF_INET, }; int fd; struct timeval timeout = { .tv_sec = 0, .tv_usec = 100, }; fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); return 1; } if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0) { perror("setsockopt"); return 1; } if (connect(fd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) { perror("connect"); return 1; } printf("connect successful\n"); return 0; } $ ./so_sndtimeo connect: Operation now in progress Signed-off-by: Tycho Andersen <tycho@tycho.pizza> Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r--man7/socket.71
1 files changed, 1 insertions, 0 deletions
diff --git a/man7/socket.7 b/man7/socket.7
index f957e1855..b1a0a0c31 100644
--- a/man7/socket.7
+++ b/man7/socket.7
@@ -838,6 +838,7 @@ just as if the socket was specified to be nonblocking.
If the timeout is set to zero (the default),
then the operation will never timeout.
Timeouts only have effect for system calls that perform socket I/O (e.g.,
+.BR connect (2),
.BR read (2),
.BR recvmsg (2),
.BR send (2),