From: hniksic Date: Mon, 4 Jul 2005 00:55:12 +0000 (-0700) Subject: [svn] Document test_socket_open. X-Git-Tag: v1.13~807 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=3d66119d345a58ab34ab996574113f619e3e16fc [svn] Document test_socket_open. --- diff --git a/src/connect.c b/src/connect.c index 35f50cc5..b85998c2 100644 --- a/src/connect.c +++ b/src/connect.c @@ -638,6 +638,17 @@ select_fd (int fd, double maxtime, int wait_for) return result; } +/* Return true iff the connection to the remote site established + through SOCK is still open. + + Specifically, this function returns true if SOCK is not ready for + reading. This is because, when the connection closes, the socket + is ready for reading because EOF is about to be delivered. A side + effect of this method is that sockets that have pending data are + considered non-open. This is actually a good thing for callers of + this function, where such pending data can only be unwanted + leftover from a previous request. */ + bool test_socket_open (int sock) { @@ -656,10 +667,8 @@ test_socket_open (int sock) /* If we get a timeout, then that means still connected */ if (select (sock + 1, &check_set, NULL, NULL, &to) == 0) - { - /* Connection is valid (not EOF), so continue */ - return true; - } + /* Connection is valid (not EOF), so continue */ + return true; else return false; }