Open xuantuan58 opened 10 years ago
I think you cannot run two servers in parallel on one TCP port. In Remact.Net I used the userContext.RequestPath during OnClientConnected to select one of several WebSocket-server-handlers that are addressed by the client on one TCP port.
@steforster Of course, I tried to run in different ports
Late to the thread, but I just ran into this also. The problem is that even if you specify a different port, the code is internally hard coded to open an additional socket on port 843 for some type of flash cross-domain stuff.
Assuming you're not using this, just set FlashAccessPolicyEnabled = false and you won't have to modify the source code.
WebSocketServer server = new WebSocketServer(port, IPAddress.Any); server.FlashAccessPolicyEnabled = false;
Then you can start multiple instances on different ports.
I have tried this project for couple days, It works great if there is only one instance of server is running. However, If runs another instance, an exception will throw
"Only one usage of each socket address (protocol/network address/port) is normally permitted".
I found that, it can fix by updating the TCPServer.cs and add a line:_listener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
There is another problem, I don't know why but the Stop() method doesn't work at all. When server calls Stop() there is nothing happens on client side, and the registered port still holds by the server.