java - Accept ServerSocket connection for multiple port -


buyersocket = new serversocket(buyer_port); sellersocket = new serversocket(seller_port); socket clientsocket = null; while (true)     {         clientsocket = sellersocket.accept();         multiserverthread x = new multiserverthread(clientsocket, dat);         x.start();          clientsocket = buyersocket.accept();         multiserverthread y = new multiserverthread(clientsocket, dat);         y.start();      } 

in block of code, waits sellersocket connect first before accepting buyersocket. suggest way accept whichever come first?

as description of accept() - listens connection made socket , accepts it. method blocks until connection made. should use method instead of accept() if want accept connection multiple ports?

the way use multithreading, because accept() method blocks until connection comes in.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -