#825 Uploads slow on Windows - nonblocking send issue

http (206)

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));

return 0;

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


  • 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.

    • milestone: 100912 --> bad_behaviour
    • status: open --> closed-fixed