Harish
Harish

Reputation: 181

Java Networking - Starting multiple Server Sockets on different ports parallely in the ame Thread

I need to start multiple ports on the Server parallely and all the server sockets should block on socket.accept().

The same Thread needs to then start the client sockets (many) to connect to particular ServerSocket(s).

Can this be achieved?

Upvotes: 0

Views: 216

Answers (1)

Alexei Kaigorodov
Alexei Kaigorodov

Reputation: 13515

No - you cannot "start multiple ports" - because ports can be used/binded, but not started.

"server sockets should block on socket.accept()" - sockets cannot block, only threads can.

"The same Thread needs to then start the client sockets" - sockets are open and closed, not started.

Upvotes: 1

Related Questions