diff --git a/docs/manual.rst b/docs/manual.rst index d73b937cc..c61958c93 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -3879,6 +3879,8 @@ session_settings int unchoke_slots_limit; int half_open_limit; int connections_limit; + + int listen_queue_size; }; ``version`` is automatically set to the libtorrent version you're using @@ -4596,6 +4598,13 @@ opened. The number of connections is set to a hard minimum of at least two per torrent, so if you set a too low connections limit, and open too many torrents, the limit will not be met. +``listen_queue_size`` is the value passed in to listen() for the listen socket. +It is the number of outstanding incoming connections to queue up while we're not +actively waiting for a connection to be accepted. The default is 5 which should +be sufficient for any normal client. If this is a high performance server which +expects to receive a lot of connections, or used in a simulator or test, it +might make sense to raise this number. It will not take affect until listen_on() +is called again (or for the first time). pe_settings =========== diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index fb76cf717..6755a6122 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -233,6 +233,7 @@ namespace libtorrent , unchoke_slots_limit(8) , half_open_limit(0) , connections_limit(200) + , listen_queue_size(5) {} // libtorrent version. Used for forward binary compatibility @@ -892,6 +893,11 @@ namespace libtorrent // the max number of connections in the session int connections_limit; + + // this is the number passed in to listen(). i.e. + // the number of connections to accept while we're + // not waiting in an accept() call. + int listen_queue_size; }; #ifndef TORRENT_DISABLE_DHT diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 0081e33f5..69493385c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1455,7 +1455,7 @@ namespace aux { return listen_socket_t(); } s.external_port = s.sock->local_endpoint(ec).port(); - s.sock->listen(5, ec); + s.sock->listen(m_settings.listen_queue_size, ec); if (ec) { if (m_alerts.should_post())