Artificial 63 connection limit on Windows #2408

issue jeremysawicki openend this issue on March 24, 2013
  1. jeremysawicki commented at 4:12 am on March 24, 2013: none

    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.

  2. luke-jr commented at 5:42 am on March 24, 2013: member

    Agreed.

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

  3. sipa commented at 11:08 pm on April 25, 2013: member
    I turned this into a pull request: #2569
  4. sipa commented at 11:16 pm on April 25, 2013: 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()?
  5. jeremysawicki commented at 11:33 pm on April 25, 2013: none
    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.
  6. sipa commented at 11:37 pm on April 25, 2013: 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…
  7. luke-jr commented at 11:49 pm on April 25, 2013: member
    @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..
  8. sipa commented at 11:09 pm on April 29, 2013: member
    Solved in #2569
  9. sipa closed this on Apr 29, 2013

  10. DrahtBot locked this on Sep 8, 2021


jeremysawicki luke-jr sipa

Milestone
v0.8.2


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-03-31 15:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me