easiest method for one UDPSelector listening on multiple ports

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

easiest method for one UDPSelector listening on multiple ports

Radim Kolar
is easiest method how to make one udpselector instance listen on multiple
ports something like this?

Controller ct=new Controller();
sh=new UPDSelectorHandle();
sh.setSelector(Selector.open());
/* now register channels */
sh.register(channel1,READ);
sh.register(channel2,READ);
ct.addSelectorHandler(sh);

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: easiest method for one UDPSelector listening on multiple ports

Oleksiy Stashok
Hello Radim,

Think in any case you will need to create 2 separate UDPSelectorHandler
instances and add the to Controller.
Using UDPSelectorHandler.setPort(...) you can set the port number to
listen on.

And don't make this "selectorHandler.setSelector(...)" as
SelectorHandler will create Selector itself.

So basically it should look like:

Controller controller = new Controller();
UDPSelectorHandler udpSelectorHandler1 = new UDPSelectorHandler();
udpSelectorHandler1.setPort(port1);

UDPSelectorHandler udpSelectorHandler2 = new UDPSelectorHandler();
udpSelectorHandler1.setPort(port2);

controller.addSelectorHandler(udpSelectorHandler1);
controller.addSelectorHandler(udpSelectorHandler2);

S pozdravem :) ,
Alexey.

Radim Kolar SF.NET wrote:

> is easiest method how to make one udpselector instance listen on multiple
> ports something like this?
>
> Controller ct=new Controller();
> sh=new UPDSelectorHandle();
> sh.setSelector(Selector.open());
> /* now register channels */
> sh.register(channel1,READ);
> sh.register(channel2,READ);
> ct.addSelectorHandler(sh);
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]