Skip to content

Artificial 63 connection limit on Windows #2408

Closed

Description

@jeremysawicki

On Windows, select() is limited to 64 sockets by default. As a result, Bitcoin can communicate with no more than 63 peers. (Not 64, because the listening socket is also passed to select().) The default value of maxconnections=125 can never be reached.

Since listening nodes are important to the network, this may be worth fixing. All it takes is "#define FD_SETSIZE 1024" (or some other number greater than 64) before "#include <winsock2.h>" in compat.h. I tried it locally and now have over 100 connections.

Activity

  1. luke-jr commented on Mar 24, 2013

    @luke-jr
    Contributor

    Agreed.

    Side note: Windows has stupidly inefficient FD_SET and FD_ISSET macros that iterate over an array to find the end

  2. sipa commented on Apr 25, 2013

    @sipa
    Member

    I turned this into a pull request: #2569

  3. sipa commented on Apr 25, 2013

    @sipa
    Member

    @luke-jr With 1000 file descriptors, that effectively means O(1M) operations to construct these sets, which seems ridiculous. Is there any reason not to switch to using poll()?

  4. jeremysawicki commented on Apr 25, 2013

    @jeremysawicki
    Author

    At least the performance penalty only occurs when the larger number of descriptors is actually used. If maxconnections=125, there are at most 125^2 = 15-16k operations, even if FD_SETSIZE is 1024.

  5. sipa commented on Apr 25, 2013

    @sipa
    Member

    @jeremysawicki Sure, it's no argument against this pull request - it's a strict improvement. Nonetheless, it's something we should look at. It seems Windows only has a poll()-like call as of Vista though, and currently we try to be compatible with XP...

  6. luke-jr commented on Apr 25, 2013

    @luke-jr
    Contributor

    @sipa Windows doesn't have poll(). Vista and newer (only) do have a WSAPoll which was supposed to emulate poll(), but has some weird bugs that someone would need to look more into if it were used..

  7. sipa commented on Apr 29, 2013

    @sipa
    Member

    Solved in #2569

  8. locked as resolved and limited conversation to collaborators on Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions