Package org.jboss.netty.bootstrap

Examples of org.jboss.netty.bootstrap.ConnectionlessBootstrap


    public static void main(String[] args) throws Exception {
        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 QuoteOfTheMomentServerHandler());
            }
        });

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

        // 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));

        // Bind to the port and start the service.
        b.bind(new InetSocketAddress(8080));
    }
View Full Code Here


    @BeforeClass
    public static void setupChannel() {
        final NioDatagramChannelFactory channelFactory = new NioDatagramChannelFactory(
                Executors.newCachedThreadPool());
        final ConnectionlessBootstrap sb = new ConnectionlessBootstrap(channelFactory);
        inetSocketAddress = new InetSocketAddress("localhost", 9999);
        sc = sb.bind(inetSocketAddress);
        final SimpleHandler handler = new SimpleHandler();
        sc.getPipeline().addFirst("handler", handler);
    }
View Full Code Here

    }

    public void clientBootstrap() {
        final NioDatagramChannelFactory channelFactory = new NioDatagramChannelFactory(
                Executors.newCachedThreadPool());
        final ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(channelFactory);
        bootstrap.getPipeline().addLast("test", new SimpleHandler());
        bootstrap.setOption("tcpNoDelay", true);
        bootstrap.setOption("keepAlive", true);
        InetSocketAddress clientAddress = new InetSocketAddress("localhost",
                8888);
        bootstrap.setOption("localAddress", clientAddress);

        ChannelFuture ccf = bootstrap.connect(inetSocketAddress);
        ccf.awaitUninterruptibly();

        Channel cc = ccf.getChannel();
        final String payload = "client payload";
        ChannelFuture write = cc.write(ChannelBuffers.wrappedBuffer(payload
View Full Code Here

    runner = executor;

    final DatagramChannelFactory channelFactory = new NioDatagramChannelFactory(
        runner);

    boot = new ConnectionlessBootstrap(channelFactory);

    final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF(
        this);

    boot.setPipelineFactory(pipelineFactory);
View Full Code Here

    runner = executor;

    final DatagramChannelFactory channelFactory = new NioDatagramChannelFactory(
        runner);

    boot = new ConnectionlessBootstrap(channelFactory);

    final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF(
        this);

    boot.setPipelineFactory(pipelineFactory);
View Full Code Here

    runner = executor;

    final DatagramChannelFactory channelFactory = new NioDatagramChannelFactory(
        runner);

    boot = new ConnectionlessBootstrap(channelFactory);

    final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF(
        this);

    boot.setPipelineFactory(pipelineFactory);
View Full Code Here

    runner = executor;

    final DatagramChannelFactory channelFactory = new NioDatagramChannelFactory(
        runner);

    boot = new ConnectionlessBootstrap(channelFactory);

    final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF(
        this);

    boot.setPipelineFactory(pipelineFactory);
View Full Code Here

    runner = executor;

    final DatagramChannelFactory channelFactory = new NioDatagramChannelFactory(
        runner);

    boot = new ConnectionlessBootstrap(channelFactory);

    final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF(
        this);

    boot.setPipelineFactory(pipelineFactory);
View Full Code Here

        if (receiveExecutor != null)
            configureThreadPool(getReceiveExecutorName(), receiveExecutor);

        this.channelFactory = isSendToServerInsteadOfMulticast() ? new NioDatagramChannelFactory(workerExecutor) : new OioDatagramChannelFactory(workerExecutor);
        this.bootstrap = new ConnectionlessBootstrap(channelFactory);
        this.bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(4096));

        bootstrap.setPipelineFactory(new UdpMessagePipelineFactory(LOG, new ChannelNodeAddressResolver(addressResolver), receiveExecutor) {
            @Override
            public ChannelPipeline getPipeline() throws Exception {
View Full Code Here

        if (receiveExecutor != null)
            configureThreadPool(getReceiveExecutorName(), receiveExecutor);

        this.channelFactory = isSendToServerInsteadOfMulticast() ? new NioDatagramChannelFactory(workerExecutor) : new OioDatagramChannelFactory(workerExecutor);
        this.bootstrap = new ConnectionlessBootstrap(channelFactory);
        this.bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(4096));

        bootstrap.setPipelineFactory(new UdpMessagePipelineFactory(LOG, new ChannelNodeAddressResolver(addressResolver), receiveExecutor) {

            @Override
View Full Code Here

TOP

Related Classes of org.jboss.netty.bootstrap.ConnectionlessBootstrap

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.