Search in sources :

Example 1 with FixedReceiveBufferSizePredictor

use of org.jboss.netty.channel.FixedReceiveBufferSizePredictor in project feeyo-hlsserver by variflight.

the class UdpServer method startup.

public void startup(int port) {
    ChannelFactory channelFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool());
    bootstrap = new ConnectionlessBootstrap(channelFactory);
    bootstrap.setOption("reuseAddress", false);
    bootstrap.setOption("child.reuseAddress", false);
    // 15M
    bootstrap.setOption("readBufferSize", 1024 * 1024 * 15);
    bootstrap.setOption("writeBufferSize", 1024 * 20);
    bootstrap.setOption("receiveBufferSizePredictor", new FixedReceiveBufferSizePredictor(1024 * 3));
    bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(1024 * 3));
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = Channels.pipeline();
            pipeline.addLast("handler", new UdpServerChannelHandler());
            return pipeline;
        }
    });
    datagramChannel = (DatagramChannel) bootstrap.bind(new InetSocketAddress(port));
}
Also used : FixedReceiveBufferSizePredictor(org.jboss.netty.channel.FixedReceiveBufferSizePredictor) NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) InetSocketAddress(java.net.InetSocketAddress) NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) ChannelFactory(org.jboss.netty.channel.ChannelFactory) FixedReceiveBufferSizePredictorFactory(org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)1 ChannelFactory (org.jboss.netty.channel.ChannelFactory)1 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)1 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)1 FixedReceiveBufferSizePredictor (org.jboss.netty.channel.FixedReceiveBufferSizePredictor)1 FixedReceiveBufferSizePredictorFactory (org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory)1 NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)1