[Python-Dev] Pervasive socket failures on Windows (original) (raw)

Tim Peters tim.peters at gmail.com
Fri Feb 10 22:35:49 CET 2006


[Martin v. Löwis]

I think the Windows interpretation is actually well-designed: FDSETSIZE shouldn't be the number of the largest descriptor, but instead be the maximum size of the set.

It's more that the fdset macros were well designed: correct code using FD_SET() etc is portable across Windows and Linux, and that's so because the macros define an interface rather than an implementation. BTW, note that the first argument to select() is ignored on Windows.

So FDSETSIZE is 64 on Windows,

In Python FD_SETSIZE is 512 on Windows (see the top of selectmodule.c).

but you still can have much larger file descriptor numbers.

Which is the source of "the problem" on Windows: Windows socket handles aren't file descriptors (if they were, they'd be little integers ;-)).

... In any case, POSIX makes it undefined what FDSET does when the socket is larger than FDSETSIZE, and apparently clearly expects an fdset to be a bit mask.

Yup -- although the people who designed the fdset macros to begin with didn't appear to have this assumption.



More information about the Python-Dev mailing list