Eli Zaretskii <e...@gnu.org> writes: > Sorry, I don't understand this comment. fd is indeed a file > descriptor, but ioctlsocket's first argument is a SOCKET object, which > is an unsigned int, and we get it from a call to `socket' or some > such. So where do you see a potential problem? > > And anyway, I think wget calls ioctlsocket for every connection; if > so, then most of those calls succeed, because the binary I built works > and is quite capably of fetching via HTTP. So these problems seem to > be triggered by something specific in those 3 tests.
sorry I wasn't clear. We use gnulib replacements for socket functions so internally wget knows only about file descriptors. On Windows this abstraction is obtained trough "_open_osfhandle" on a SOCKET object. When we use a native function, like "ioctlsocket", we have to be sure the file descriptor is converted back to a SOCKET object (by using _get_osfhandle). I am afraid this conversion is not done correctly, the value you have observed (fd = 3) let me think so. The "w32sock.h" file from gnulib defines these two macros for such conversions: #define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) #define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY)) Cheers, Giuseppe