diff --git a/src/Tcp/TcpServers.cs b/src/Tcp/TcpServers.cs index 73a0ef55..ec5f4b20 100644 --- a/src/Tcp/TcpServers.cs +++ b/src/Tcp/TcpServers.cs @@ -58,7 +58,10 @@ public override void Open(Host host, int backlog) onModifyHandler?.Invoke(null, m_socket); m_socket.Bind(host.EndPoint); - m_socket.Listen(backlog); + + const int maxBacklog = (int)SocketOptionName.MaxConnections; + int backlogClamped = (backlog <= 0 || backlog >= maxBacklog) ? maxBacklog : backlog; + m_socket.Listen(backlogClamped); Host = new Host(m_socket.LocalEndPoint);