]> sjero.net Git - wget/blobdiff - src/connect.c
[svn] Move fnmatch() to cmpt.c and don't use it under GNU libc.
[wget] / src / connect.c
index f12225d8f9f5eece00477bc61bb74d9b97bb208c..96c7c3193761c39bb74f4a2fc349c31ad71b9445 100644 (file)
@@ -37,16 +37,14 @@ so, delete this exception statement from your version.  */
 #endif
 #include <assert.h>
 
-#ifdef WINDOWS
-# include <winsock.h>
-#else
+#ifndef WINDOWS
 # include <sys/socket.h>
 # include <netdb.h>
 # include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#endif
-#endif /* WINDOWS */
+# ifndef __BEOS__
+#  include <arpa/inet.h>
+# endif
+#endif /* not WINDOWS */
 
 #include <errno.h>
 #ifdef HAVE_STRING_H
@@ -176,19 +174,22 @@ connect_to_one (ip_address *addr, unsigned short port, int silent)
   if (sock < 0)
     goto out;
 
-#ifdef SO_RCVBUF
   /* For very small rate limits, set the buffer size (and hence,
      hopefully, the size of the kernel window) to the size of the
-     limit.  */
+     limit.  That way we don't sleep for more than 1s between network
+     reads.  */
   if (opt.limit_rate && opt.limit_rate < 8192)
     {
       int bufsize = opt.limit_rate;
       if (bufsize < 512)
        bufsize = 512;
+#ifdef SO_RCVBUF
       setsockopt (sock, SOL_SOCKET, SO_RCVBUF,
                  (char *)&bufsize, sizeof (bufsize));
-    }
 #endif
+      /* When we add opt.limit_rate support for writing, as with
+        `--post-file', also set SO_SNDBUF here.  */
+    }
 
   resolve_bind_address ();
   if (bind_address_resolved)
@@ -198,7 +199,7 @@ connect_to_one (ip_address *addr, unsigned short port, int silent)
       wget_sockaddr_set_address (&bsa, ip_default_family, 0, &bind_address);
       if (bind (sock, &bsa.sa, sockaddr_len ()))
        {
-         close (sock);
+         CLOSE (sock);
          sock = -1;
          goto out;
        }
@@ -208,7 +209,7 @@ connect_to_one (ip_address *addr, unsigned short port, int silent)
   if (connect_with_timeout (sock, &sa.sa, sockaddr_len (),
                            opt.connect_timeout) < 0)
     {
-      close (sock);
+      CLOSE (sock);
       sock = -1;
       goto out;
     }