OioDatagramChannelFactory for client and server?

Trustin Lee tlee at redhat.com
Mon Apr 20 06:31:25 EDT 2009


You do not need to use ServerBootstrap for the UDP transport.  Could
you please read the QOTM example?

— Trustin Lee, http://gleamynode.net/

On Mon, Apr 20, 2009 at 6:31 PM, hezjing <hezjing at gmail.com> wrote:
> 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
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
>




More information about the netty-users mailing list