cURL / Mailing Lists / curl-library / Single Mail

curl-library

cURL on Windows with _WIN32_WINNT=0x0600 suffers from WSAPoll bug

From: Jan Koen Annot <Jan-Koen.Annot_at_infor.com>
Date: Tue, 31 Jul 2012 13:28:56 +0000

When building the cURL library on Windows with _WIN32_WINNT=0x0600, cURL will use the WSAPoll API function (available in Vista and higher).
However, cURL will suffer from a bug in WSAPoll.
When the cURL library is used to setup a connection to an incorrect port, normally the result is CURLE_COULDNT_CONNECT, /* 7 */, but due to the bug in WSAPoll, the result now is CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */.
See for example http://social.msdn.microsoft.com/Forums/hu/wsk/thread/18769abd-fca0-4d3c-9884-1a38ce27ae90 ("WSAPoll and non-blocking connects to non-existent ports").
The bug in WSAPoll is also demonstrated in the attached program TestSocketConnect.cpp.
Adapt lines 141 and 142 to specify IP address and port number. In my case:
                TestSocketConnection("10.21.46.81", 443, lTimeout);
                TestSocketConnection("10.21.46.81", 8443, lTimeout);
Port 443 is not available, port 8443 works fine.
Output of the program (specify timeout in ms on command line, default is 1000):
=============
Hello, world!
WSAStartup returned 0.

lSOCKET is 0x00000074.
ioctlsocket(FIONBIO, 1) returned 0.
connecting to 10.21.46.81, port 443.
connect() returned -1.
WSAGetLastError() returned 10035.

WSAPoll(timeout=1000ms) returned 0.
lWSAPOLLFD.revents is 0x00
getsockopt() returned 0, lError is 10061.

closesocket() returned 0.

lSOCKET is 0x00000074.
ioctlsocket(FIONBIO, 1) returned 0.
connecting to 10.21.46.81, port 8443.
connect() returned -1.
WSAGetLastError() returned 10035.

WSAPoll(timeout=1000ms) returned 1.
lWSAPOLLFD.revents is 0x10
getsockopt() returned 0, lError is 0.

closesocket() returned 0.

WSACleanup returned 0.
Bye, world!
=============

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2012-07-31