Socket server acceots only one client
Monkey Forums/Monkey Bug Reports/Socket server acceots only one client
| ||
Hey all, I'm not the first having this problem but at least using the desktop target I don't get a simple tcp server to work with more than one client. Here's the server: Here's the client: |
| ||
I discovered the same issue already. I add _socket.AcceptAsync( Self ) to the end of OnAcceptComplete method Method OnAcceptComplete:Void( socket:Socket, source:Socket ) If( Not socket ) Error "Accept error" Local client:TcpClient = New TcpClient( socket ) _clients.AddLast( client ) Print1("New client " + socket.RemoteAddress.ToString()) Print1 "Accepted client connection" Print1 "Connected clients: " + _clients.Count() _socket.AcceptAsync( Self ) End Method |
| ||
Anyway count of opened sockets is limited 256 by default setting in "socket.monkey" |
| ||
Yes, you must call AcceptAsync again inside OnAcceptComplete in order to accept multiple connections. > Anyway count of opened sockets is limited 256 by default setting in "socket.monkey" I don't think so - what code are you referring to? There is a 'command queue' in there that's 256 bytes long, but it's utter overkill and should probably be removed altogether as it'll just confuse things even more if I attempt to describe what it does! |
| ||
marksibly wrote: I don't think so - what code are you referring to? There is a 'command queue' in there that's 256 bytes long, but it's utter overkill and should probably be removed altogether as it'll just confuse things even more if I attempt to describe what it does! Ops. I misunderstand how to asyncop queue works. AcceptAsync() and other methods add new asynevent into queue until size of queue does not overflow limit (QUEUE_SIZE). but I don't see the code to remove items from queue in the socket.monkey... |
| ||
Yes, you must call AcceptAsync again inside OnAcceptComplete in order to accept multiple connections. Oh well thanks Mark, that was the problem! :) |