the best way to talk to multiple UDP/TCP servers?

Alan Bateman Alan.Bateman at oracle.com
Thu Apr 24 08:19:50 UTC 2014


On 18/04/2014 16:21, Wang Weijun wrote:
> I'm writing a client which talks to 3 servers, and would like to write a method that
>
>    sends request to server 1 at time 0:01
>    sends request to server 2 at time 0:02
>    sends request to server 3 at time 0:03
>    sends request to server 1 at time 0:11
>    sends request to server 2 at time 0:12
>    sends request to server 3 at time 0:13
>    waits until 0:20
>
> During this whole period, whenever a response from a server is received, the method returns and no more request is sent. The protocol can be UDP or TCP. What is the best way I can do this with NIO?
>
You should be able to do this with non-blocking I/O and Selector, have 
you looked into that?

-Alan.


More information about the nio-dev mailing list