UDP Listener

alex_ab_sw boga.alexa at gmail.com
Thu Aug 11 09:50:10 EDT 2011


Hello,

I am trying to write a component in an application that will listen on UDP
for multicast messages, but somehow I don't receive any messages while with
a MulticastSocket I can see the messages landing fine.

Here is the piece of code that I am talking about:
---------------------------------------------------------------
        DatagramChannelFactory channelFactory = new
OioDatagramChannelFactory(Executors.newCachedThreadPool());
        ConnectionlessBootstrap bootstrap = new
ConnectionlessBootstrap(channelFactory);
        
        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
            @Override
            public ChannelPipeline getPipeline() {
                return Channels.pipeline(messageDecoder, multicastHandler);
            }
        });
        
        bootstrap.setOption("receiveBufferSizePredictorFactory", new
FixedReceiveBufferSizePredictorFactory(
                maxPacketSize));
        
        
        logger.info("... binding the DatagramChannel on new
InetSocketAddress {}:{}", localIpAddress, multicastPort);
        DatagramChannel datagramChannel = (DatagramChannel)
        bootstrap.bind(new InetSocketAddress(localIpAddress,
multicastPort));

        try {
            InetAddress multicastAddress =
InetAddress.getByName(multicastIpAddress);
            datagramChannel.joinGroup(multicastAddress);
        } catch (UnknownHostException e) {
            shutdown();
        }
------------------------------------------------------------
Can you tell if I am doing something wrong, because I see no errors on logs
but also no messages coming. The component is deployed on a Linux box with
CentOS on it.

Thanks in advance.

--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/UDP-Listener-tp6676456p6676456.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list