Skip to content

Commit

Permalink
fix #35 (Sockets problem on Android build)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alec1o committed Feb 8, 2024
1 parent 126b64c commit db1eda4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Tcp/TcpServers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit db1eda4

Please sign in to comment.