Package org.jboss.netty.channel.socket.nio

Examples of org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory


public class OioNioDatagramTest extends AbstractDatagramTest{

    @Override
    protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) {
        return new NioDatagramChannelFactory(executor);
    }
View Full Code Here


@Ignore
public class OioNioDatagramMulticastTest extends AbstractDatagramMulticastTest {

    @Override
    protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) {
        return new NioDatagramChannelFactory(executor, InternetProtocolFamily.IPv4);
    }
View Full Code Here

public class NioOioDatagramTest extends AbstractDatagramTest{

    @Override
    protected DatagramChannelFactory newClientSocketChannelFactory(Executor executor) {
        return new NioDatagramChannelFactory(executor);
    }
View Full Code Here

        return new OioDatagramChannelFactory(executor);
    }

    @Override
    protected DatagramChannelFactory newClientSocketChannelFactory(Executor executor) {
        return new NioDatagramChannelFactory(executor, InternetProtocolFamily.IPv4);
    }
View Full Code Here

public class NioNioDatagramTest extends AbstractDatagramTest {

    @Override
    protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) {
        return new NioDatagramChannelFactory(executor);
    }
View Full Code Here

        return new NioDatagramChannelFactory(executor);
    }

    @Override
    protected DatagramChannelFactory newClientSocketChannelFactory(Executor executor) {
        return new NioDatagramChannelFactory(executor);
    }
View Full Code Here

        this.port = port;
    }

    public void run() {
        DatagramChannelFactory f =
            new NioDatagramChannelFactory(Executors.newCachedThreadPool());

        ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);

        // Configure the pipeline factory.
        b.setPipelineFactory(new ChannelPipelineFactory() {
            public ChannelPipeline getPipeline() throws Exception {
                return Channels.pipeline(
                        new StringEncoder(CharsetUtil.ISO_8859_1),
                        new StringDecoder(CharsetUtil.ISO_8859_1),
                        new QuoteOfTheMomentClientHandler());
            }
        });

        // Enable broadcast
        b.setOption("broadcast", "true");

        // Allow packets as large as up to 1024 bytes (default is 768).
        // You could increase or decrease this value to avoid truncated packets
        // or to improve memory footprint respectively.
        //
        // Please also note that a large UDP packet might be truncated or
        // dropped by your router no matter how you configured this option.
        // In UDP, a packet is truncated or dropped if it is larger than a
        // certain size, depending on router configuration.  IPv4 routers
        // truncate and IPv6 routers drop a large packet.  That's why it is
        // safe to send small packets in UDP.
        b.setOption(
                "receiveBufferSizePredictorFactory",
                new FixedReceiveBufferSizePredictorFactory(1024));

        DatagramChannel c = (DatagramChannel) b.bind(new InetSocketAddress(0));

        // Broadcast the QOTM request to port 8080.
        c.write("QOTM?", new InetSocketAddress("255.255.255.255", port));

        // QuoteOfTheMomentClientHandler will close the DatagramChannel when a
        // response is received.  If the channel is not closed within 5 seconds,
        // print an error message and quit.
        if (!c.getCloseFuture().awaitUninterruptibly(5000)) {
            System.err.println("QOTM request timed out.");
            c.close().awaitUninterruptibly();
        }

        f.releaseExternalResources();
    }
View Full Code Here

    public QuoteOfTheMomentServer(int port) {
        this.port = port;
    }

    public void run() {
        DatagramChannelFactory f = new NioDatagramChannelFactory();
        ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);

        // Configure the pipeline factory.
        b.setPipelineFactory(new ChannelPipelineFactory() {
            public ChannelPipeline getPipeline() throws Exception {
View Full Code Here

    }

    private void initializeUDPServerSocketCommunicationLayer() throws Exception {
        workerExecutor = context.getExecutorServiceManager().newCachedThreadPool(this, "NettyUDPWorker");
        if (configuration.getWorkerCount() <= 0) {
            datagramChannelFactory = new NioDatagramChannelFactory(workerExecutor);
        } else {
            datagramChannelFactory = new NioDatagramChannelFactory(workerExecutor, configuration.getWorkerCount());
        }
        connectionlessServerBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
        connectionlessServerBootstrap.setOption("child.keepAlive", configuration.isKeepAlive());
        connectionlessServerBootstrap.setOption("child.tcpNoDelay", configuration.isTcpNoDelay());
        connectionlessServerBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
View Full Code Here

    protected void setupUDPCommunication() throws Exception {
        if (datagramChannelFactory == null) {
            workerExecutor = context.getExecutorServiceManager().newCachedThreadPool(this, "NettyUDPWorker");
            if (configuration.getWorkerCount() <= 0) {
                datagramChannelFactory = new NioDatagramChannelFactory(workerExecutor);
            } else {
                datagramChannelFactory = new NioDatagramChannelFactory(workerExecutor, configuration.getWorkerCount());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.