Java Server – Multiple ports?

It’s not possible to for a single instance of ServerSocket to listen to multiple ports. You can of course have multiple ServerSockets. However, as you already know, ServerSocket.accept blocks. What you can use instead is a ServerSocketChannel. They’re used in a similar way, but do not block. If there are no pending connections when ServerSocketChannel.accept … Read more