users@grizzly.java.net

Re: easiest method for one UDPSelector listening on multiple ports

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Wed, 24 Oct 2007 10:19:22 +0200

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: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>