Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem with FD_SETSIZE on Windows  (Read 3263 times)

0 Members and 1 Guest are viewing this topic.

SpaceManiac

  • Newbie
  • *
  • Posts: 1
    • View Profile
Problem with FD_SETSIZE on Windows
« on: July 15, 2014, 10:34:01 pm »
This commit (June 9) appears to break SocketSelector on Windows:
https://github.com/SFML/SFML/commit/228038fa8a9cf0c90e1067dcc12c177bb77c8bab
Related issues:
https://github.com/SFML/SFML/issues/153
https://github.com/SFML/SFML/pull/628

The check that this code performs:
        if (handle < FD_SETSIZE)
        {
            FD_SET(handle, &m_impl->AllSockets);

            int size = static_cast<int>(handle);
            if (size > m_impl->MaxSocket)
                m_impl->MaxSocket = size;
        }
        else
        {
            err() << "The socket can't be added to the selector because its "
                  << "ID is too high. This is a limitation of your operating "
                  << "system's FD_SETSIZE setting.";
        }
isn't applicable to Windows. Under Windows, FD_SETSIZE describes the maximum number of sockets which an fd_set can contain, rather than the maximum file descriptor, and is also very low (64 on my system). This means sockets with a descriptor of 64 or above (which seems to be most of them) can't be added due to this check, even though without this check it works fine.

Here's some simple code demonstrating the problem:
#include <SFML/Network.hpp>

int main() {
    sf::TcpListener listener;
    sf::SocketSelector selector;

    listener.listen(15000);
    selector.add(listener);
}
 

I was able to fix the issue locally by reverting the noted commit. Any insight? Should this go on the GitHub tracker?
« Last Edit: July 15, 2014, 10:58:17 pm by SpaceManiac »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Problem with FD_SETSIZE on Windows
« Reply #1 on: July 15, 2014, 11:09:13 pm »
You're right, I've reopened the issue. Thanks for the feedback.
Laurent Gomila - SFML developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Problem with FD_SETSIZE on Windows
« Reply #2 on: July 17, 2014, 07:07:43 am »
This should be fixed with this patch.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).