From db1eda4de5b891b83578a676f11a9e0b197756ff Mon Sep 17 00:00:00 2001 From: Alecio Furanze Date: Thu, 8 Feb 2024 15:52:52 +0200 Subject: [PATCH] ``fix`` #35 ``(Sockets problem on Android build)`` The cause of this error is because ``TCP Backlog`` by default was using ``0`` and searching ``TcpListener`` api it was using ``2147483647``. To fix it needed update default value to ``2147483647`` or diferent by zero or negative value. --- src/Tcp/TcpServers.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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);