List of usage examples for io.netty.channel ChannelOption SO_BACKLOG
ChannelOption SO_BACKLOG
To view the source code for io.netty.channel ChannelOption SO_BACKLOG.
Click Source Link
From source file:org.opendaylight.usc.test.EchoServerTcp.java
License:Open Source License
public EchoServerTcp(final boolean enableEncryption, int port) { PORT = port;/*from w ww .j av a 2s . c o m*/ UscConfigurationServiceImpl.setDefaultPropertyFilePath("resources/etc/usc/usc.properties"); secureService = UscServiceUtils.getService(UscSecureService.class); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100) .handler(new LoggingHandler("EchoServerTcp server handler", LogLevel.TRACE)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { System.out.println("EchoServerTcp initChannel"); ChannelPipeline p = ch.pipeline(); if (enableEncryption) { p.addLast(new LoggingHandler("EchoServerTcp Handler 3", LogLevel.TRACE)); p.addLast(secureService.getTcpServerHandler(ch)); } p.addLast(new LoggingHandler("EchoServerTcp Handler 2", LogLevel.TRACE)); p.addLast(new EchoServerTcpHandler()); p.addLast(new LoggingHandler("EchoServerTcp Handler 1", LogLevel.TRACE)); } }); }
From source file:org.opendaylight.usc.test.plugin.EchoServerTcp.java
License:Open Source License
public EchoServerTcp(final boolean enableEncryption, int port) { PORT = port;//from w w w. j a va 2 s . com UscConfigurationServiceImpl.setDefaultPropertyFilePath("src/test/resources/etc/usc/usc.properties"); secureService = UscServiceUtils.getService(UscSecureService.class); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100) .handler(new LoggingHandler("EchoServerTcp server handler", LogLevel.TRACE)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); if (enableEncryption) { p.addLast(new LoggingHandler("EchoServerTcp Handler 3", LogLevel.TRACE)); p.addLast(secureService.getTcpServerHandler(ch)); } p.addLast(new LoggingHandler("EchoServerTcp Handler 2", LogLevel.TRACE)); p.addLast(new EchoServerTcpHandler()); p.addLast(new LoggingHandler("EchoServerTcp Handler 1", LogLevel.TRACE)); } }); }
From source file:org.openremote.agent.protocol.io.AbstractIoServer.java
License:Open Source License
/** * Configure options to be applied to the server's own IO channel */ protected void configureServerChannelOptions() { bootstrap.option(ChannelOption.SO_BACKLOG, clientLimit); }
From source file:org.piindustries.pinetwork.server.Server.java
License:Apache License
public void run() throws Exception { // Configure the server. EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); try {/*from w w w .j a v a 2s. c o m*/ ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast( //new LoggingHandler(LogLevel.INFO), new ServerHandler()); } }); // Start the server. ChannelFuture f = b.bind(port).sync(); // Wait until the server socket is closed. f.channel().closeFuture().sync(); } finally { // Shut down all event loops to terminate all threads. bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:org.r358.poolnetty.test.simpleserver.SimpleServer.java
License:Open Source License
public SimpleServer(String host, int port, int backLog, final SimpleServerListener ssl) throws Exception { EventLoopGroup workers = new NioEventLoopGroup(); EventLoopGroup bosses = new NioEventLoopGroup(); bootstrap = new ServerBootstrap(); bootstrap.group(bosses, workers);/*from ww w . j a v a 2s . c o m*/ bootstrap.channel(NioServerSocketChannel.class); bootstrap.childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline cpl = ch.pipeline(); cpl.addLast("encode", new SimpleOutboundHandler(-1)); cpl.addLast("decode", new SimpleInboundHandler()); cpl.addLast("adapt", new ChannelInboundHandlerAdapter() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { super.channelActive(ctx); ssl.newConnection(ctx); } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ssl.newValue(ctx, msg.toString()); } }); } }); bootstrap.localAddress(host, port); bootstrap.option(ChannelOption.ALLOW_HALF_CLOSURE, true); bootstrap.option(ChannelOption.SO_KEEPALIVE, true); bootstrap.option(ChannelOption.SO_BACKLOG, backLog); }
From source file:org.ratpackframework.bootstrap.internal.NettyRatpackService.java
License:Apache License
@Override protected void startUp() throws Exception { ServerBootstrap bootstrap = new ServerBootstrap(); group = new NioEventLoopGroup(MultithreadEventLoopGroup.DEFAULT_EVENT_LOOP_THREADS, new DefaultThreadFactory("ratpack-group", Thread.MAX_PRIORITY)); bootstrap.group(group).channel(NioServerSocketChannel.class).childHandler(channelInitializer); bootstrap.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.childOption(ChannelOption.TCP_NODELAY, true); bootstrap.option(ChannelOption.SO_REUSEADDR, true); bootstrap.option(ChannelOption.SO_BACKLOG, 1024); channel = bootstrap.bind(requestedAddress).sync().channel(); boundAddress = (InetSocketAddress) channel.localAddress(); if (logger.isLoggable(Level.INFO)) { logger.info(String.format("Ratpack started for http://%s:%s", getBindHost(), getBindPort())); }/*from w w w.ja v a 2s .c om*/ }
From source file:org.ratpackframework.server.internal.NettyRatpackService.java
License:Apache License
@Override protected void startUp() throws Exception { ServerBootstrap bootstrap = new ServerBootstrap(); group = new NioEventLoopGroup(launchConfig.getMainThreads(), new DefaultThreadFactory("ratpack-group", Thread.MAX_PRIORITY)); bootstrap.group(group).channel(NioServerSocketChannel.class).childHandler(channelInitializer) .childOption(ChannelOption.ALLOCATOR, launchConfig.getBufferAllocator()) .childOption(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_REUSEADDR, true) .option(ChannelOption.SO_BACKLOG, 1024) .option(ChannelOption.ALLOCATOR, launchConfig.getBufferAllocator()); try {// ww w . java2s. c o m channel = bootstrap.bind(buildSocketAddress()).sync().channel(); } catch (Exception e) { partialShutdown(); throw e; } boundAddress = (InetSocketAddress) channel.localAddress(); if (logger.isLoggable(Level.INFO)) { logger.info(String.format("Ratpack started for http://%s:%s", getBindHost(), getBindPort())); } }
From source file:org.restlet.engine.netty.NettyServerHelper.java
License:Open Source License
@Override public void start() throws Exception { super.start(); setBossGroup(new NioEventLoopGroup()); setWorkerGroup(new NioEventLoopGroup()); setServerBootstrap(new ServerBootstrap()); getServerBootstrap().option(ChannelOption.SO_BACKLOG, 1024); getServerBootstrap().group(getBossGroup(), getWorkerGroup()).channel(NioServerSocketChannel.class) .childOption(ChannelOption.AUTO_READ, false).localAddress(getHelped().getPort()) .childHandler(new ChannelInitializer<SocketChannel>() { @Override/*w ww .j av a 2 s . c o m*/ protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(new HttpRequestDecoder(), new HttpResponseEncoder()) .addLast("serverStreamsHandler", new HttpStreamsServerHandler()); HandlerSubscriber<HttpResponse> subscriber = new HandlerSubscriber<>(ch.eventLoop(), 2, 4); HandlerPublisher<HttpRequest> publisher = new HandlerPublisher<>(ch.eventLoop(), HttpRequest.class); pipeline.addLast("serverSubscriber", subscriber); pipeline.addLast("serverPublisher", publisher); publisher.subscribe(NettyServerHelper.this); NettyServerHelper.this.subscribe(subscriber); } }); setServerChannel(getServerBootstrap().bind().sync().channel()); setEphemeralPort(((InetSocketAddress) getServerChannel().localAddress()).getPort()); getLogger().info("Starting the Netty " + getProtocols() + " server on port " + getHelped().getPort()); }
From source file:org.restlet.ext.netty.NettyServerHelper.java
License:Open Source License
@Override public void start() throws Exception { super.start(); setBossGroup(new NioEventLoopGroup(1)); setWorkerGroup(new NioEventLoopGroup()); setServerBootstrap(new ServerBootstrap()); getServerBootstrap().option(ChannelOption.SO_BACKLOG, 1024); getServerBootstrap().group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new HttpServerInitializer(this, null)); setChannel(serverBootstrap.bind(getHelped().getPort()).sync().channel()); setEphemeralPort(((InetSocketAddress) getChannel().localAddress()).getPort()); getLogger().info("Starting the Netty " + getProtocols() + " server on port " + getHelped().getPort()); }
From source file:org.rzo.netty.ahessian.bootstrap.DefaultServer.java
License:Apache License
public DefaultServer(Class serverChannelClass, ChannelPipelineFactoryFactory factory, Set<String> channelOptions, int port) { if (!ServerChannel.class.isAssignableFrom(serverChannelClass)) throw new RuntimeException("serverChannelClass must implement ServerChannel"); // Configure the server. bootstrap = new ServerBootstrap(); _port = port;//from ww w . j a va2s . c o m internalGroup = new DefaultEventExecutorGroup(10); if (isNio(serverChannelClass)) { bossGroup = new NioEventLoopGroup(); childGroup = new NioEventLoopGroup(); } else if (isOio(serverChannelClass)) { bossGroup = new OioEventLoopGroup(); childGroup = new OioEventLoopGroup(); } else { bossGroup = new NioEventLoopGroup(); childGroup = new NioEventLoopGroup(); } bootstrap.group(bossGroup, childGroup); bootstrap.channel(serverChannelClass); // bootstrap.setOption("child.trafficClass", IPTOS_LOWDELAY); // bootstrap.setOption("child.tcpNoDelay", false); // bootstrap.childOption(ChannelOption.IP_TOS, IPTOS_THROUGHPUT); setChannelOptions(channelOptions); bootstrap.option(ChannelOption.SO_BACKLOG, 100); ChannelPipelineFactory channelPipelineFactory = factory.create(internalGroup, bootstrap); bootstrap.childHandler(channelPipelineFactory); }