- /* we cannot have more than FD_SETSIZE sockets */
- if (++max_fds > FD_SETSIZE) {
- WARN0("too many open sockets.");
+ if (max_fds == -1) {
+ if (timeout > 0) {
+ DEBUG1("No socket to select onto. Sleep %f sec instead.",timeout);
+ gras_os_sleep(timeout);
+ THROW1(timeout_error,0,"No socket to select onto. Sleep %f sec instead",timeout);
+ } else {
+ DEBUG0("No socket to select onto. Return directly.");
+ THROW0(timeout_error,0, "No socket to select onto. Return directly.");
+ }
+ }
+
+#ifndef HAVE_WINSOCK_H
+ /* we cannot have more than FD_SETSIZE sockets
+ ... but with WINSOCK which returns sockets higher than the limit (killing this optim) */
+ if (++max_fds > fd_setsize && fd_setsize > 0) {
+ WARN1("too many open sockets (%d).",max_fds);