List of usage examples for io.netty.channel DefaultMessageSizeEstimator DEFAULT
MessageSizeEstimator DEFAULT
To view the source code for io.netty.channel DefaultMessageSizeEstimator DEFAULT.
Click Source Link
From source file:org.ethereum.net.server.PeerServerImpl.java
License:Open Source License
public void start(int port) { // TODO review listening use listening = true;/* w w w . j a va2 s. c o m*/ EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); ethereumChannelInitializer = ctx.getBean(EthereumChannelInitializer.class, ""); ethereumListener.trace("Listening on port " + port); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup); b.channel(NioServerSocketChannel.class); b.option(ChannelOption.SO_KEEPALIVE, true); b.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR, DefaultMessageSizeEstimator.DEFAULT); b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.peerConnectionTimeout()); b.handler(new LoggingHandler()); b.childHandler(ethereumChannelInitializer); // Start the client. logger.info("Listening for incoming connections, port: [{}] ", port); logger.info("NodeId: [{}] ", Hex.toHexString(config.nodeId())); ChannelFuture f = b.bind(port).sync(); // Wait until the connection is closed. f.channel().closeFuture().sync(); logger.debug("Connection is closed"); // TODO review listening use listening = false; } catch (Exception e) { logger.debug("Exception: {} ({})", e.getMessage(), e.getClass().getName()); throw new Error("Server Disconnected"); } finally { workerGroup.shutdownGracefully(); } }