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

jquery - How do you format the date used in the popover widget title of FullCalendar? -

Bubble Sort Manually a Linked List in Java -

asp.net mvc - SSO between MVCForum and Umbraco7 -