Menu

#825 Uploads slow on Windows - nonblocking send issue

closed-fixed
http (206)
5
2013-06-21
2009-04-28
No

Upload speeds are capped at 80kb/sec due to a Windows Sockets API behavior w/non-blocking sockets and send.

The issue and an incorrect fix are described in Microsoft KB article: http://support.microsoft.com/kb/823764

Setting the setsockopt handler below fixed the problem:

static int set_sockopts(void * clientp, curl_socket_t sockfd, curlsocktype purpose) {
// See http://support.microsoft.com/kb/823764
#ifdef _WIN32
int val = CURL_MAX_WRITE_SIZE * 2 + 32;
setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (const char *)&val, sizeof(val));
#endif

return 0;
}

I suggest this setsockopt logic be integrated into libcurl to save others from spending a day or more tracking down the issue.

Discussion

  • Daniel Stenberg

    Daniel Stenberg - 2009-04-28

    Thanks for the report and details. I've now committed a fix, but I made the buffer only 32 bytes larger as friends at MS confirmed that to be enough.

     
  • Daniel Stenberg

    Daniel Stenberg - 2009-04-28
    • milestone: 100912 --> bad_behaviour
    • status: open --> closed-fixed