OioDatagramChannelFactory for client and server?

hezjing hezjing at gmail.com
Mon Apr 20 05:31:22 EDT 2009


Hi

I'm trying to create a UDP server with Netty 3.1 BETA2, here is the code
snippet:

        ChannelFactory factory = new
OioDatagramChannelFactory(Executors.newCachedThreadPool());
        ServerBootstrap bootstrap = new ServerBootstrap(factory);
        ChannelPipeline pipeline = bootstrap.getPipeline();
        pipeline.addLast("logger", new LoggingHandler(true));
        ...
        Channel channel = bootstrap.bind(new InetSocketAddress(listenPort));


When run, it throws the following exception:

Exception in thread "main" java.lang.IllegalArgumentException: factory must
be a ServerChannelFactory:
class org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory
    at
org.jboss.netty.bootstrap.ServerBootstrap.setFactory(ServerBootstrap.java:183)
    at org.jboss.netty.bootstrap.Bootstrap.<init>(Bootstrap.java:73)
    at
org.jboss.netty.bootstrap.ServerBootstrap.<init>(ServerBootstrap.java:174)


Do you have any idea of what could be the reason?


On Wed, Apr 8, 2009 at 4:50 PM, Trustin Lee <tlee at redhat.com> wrote:

> On Wed, Apr 8, 2009 at 5:49 PM, Trustin Lee <tlee at redhat.com> wrote:
> > On Sat, Apr 4, 2009 at 5:06 PM, hezjing <hezjing at gmail.com> wrote:
> >> Hi
> >> The Javadoc explains that OioDatagramChannelFactory is to create
> a blocking
> >> I/O based UDP client.
> >>
> >> What should we use to create a UDP server?
> >
> > Actually, you can create a UDP client using OioDatagramChannelFactory.
> >  It was a documentation mistake.  Please refer to the QOTM server
> > example.
>
> Oops.  Actually, you can create both UDP client and server using
> OioDatagramChannelFactory.  It was a documentation mistake.  Please
> refer to the QOTM server example.
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>



-- 

Hez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20090420/394ee3fe/attachment.html 


More information about the netty-users mailing list