I am trying to develop a socket server supporting TCP sockets and WebSockets. I created two ServerBootsraps with their channels and handlers. I started them with different ports with (skipping unnecessary code parts because they are working ok)
...
ChannelFuture channelFuture = serverBootstrap.bind(port);
...
...
ChannelFuture channelFutureWebsocket = serverBootstrapWebSocket.bind(webSocketPort);
In the tutorials I've seen, they were all ending with serverBootstrap.bind(port).sync();
But If I end with sync, the server stops and waits for packets and I cannot start the other server (as expected). If I don't end with sync, the server runs ok but I am doubtful if it will cause an error in the future.
If my method, skipping sync()
, is wrong, how can I run 2 different servers simultaneously?