You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do I interpret this correctly that you are effectively allowing only a single client to connect? Even though the maximum amount of connections is set to 5 in the call to listen an established connection is dropped as soon as a new connection request is issued.
The text was updated successfully, but these errors were encountered:
This is an old issue, and I think your interpretation is mostly correct there can only really be one active accepted connection at a time. I think you're slightly misinterpreting what listen does though.
5 in the call to listen isn't the maximum number of connections. It's the maximum number of clients that can be queued up waiting for a connection. Theoretically a socket server (not this one) that calls listen with 5 as a parameter could have dozens of accepted client connections; its queue of unaccepted client connections could only be 5 though.
The fact that this implementation of accept calls close on the current connection though is definitely limiting and somewhat single client.
Its very limitedly multi client though in the sense that clients do enter the queue. So theoretically you could have a timeline like:
create server
create client1 connected to server
create client2 connected to server
client1 sends j1
client2 sends j2
client1 sends j3
server accept (connects to client1)
server recv returns j1
server recv returns j3
server send here would only go to current connection (client1)
server accept (connects to client2 closes client1)
server recv returns j2 (this waits in the queue too even though it wasn't accepted until after it was sent)
If the server queue was full, the client call to connect would block and time out.
Do I interpret this correctly that you are effectively allowing only a single client to connect? Even though the maximum amount of connections is set to 5 in the call to listen an established connection is dropped as soon as a new connection request is issued.
The text was updated successfully, but these errors were encountered: