src/main/java/hu/trigary/simplenetty/server/Server.java
/**
	 * Starts the server synchronously. Once it is completed, the server is ready to receive connections.
	 *
	 * @param host the address of the server, can be null
	 * @param port the port of the server
	 * @throws InterruptedException if the thread gets interrupted while
	 * the {@code host} and {@code port} are being bound
	 */
Starts the server synchronously. Once it is completed, the server is ready to receive connections.
@param host the address of the server, can be null
@param port the port of the server
@throws InterruptedException if the thread gets interrupted while
the  host and  port are being bound
Starts the server synchronously . Once it is completed the server is ready to receive connections . @param host the address of the server can be null @param port the port of the server @throws InterruptedException if the thread gets interrupted while the host and port are being bound
public void start(String host, int port) throws InterruptedException {
		ServerBootstrap bootstrap = new ServerBootstrap();
		bossGroup = new NioEventLoopGroup();
		workerGroup = new NioEventLoopGroup();
		bootstrap.group(bossGroup, workerGroup)
				.channel(NioServerSocketChannel.class)
				.childHandler(new ChannelInitializer<SocketChannel>() {
					@Override
					public void initChannel(SocketChannel channel) {
						channel.pipeline().addLast(new PacketDecoder<>(serializer),
								new LengthFieldPrepender(4),
								new PacketEncoder<>(serializer),
								new ServerChannelHandler());
						Consumer<SocketChannel> consumer = onChannelInitialized;
						if (consumer != null) {
							consumer.accept(channel);
						}
					}
				})
				.option(ChannelOption.SO_BACKLOG, 128)
				.childOption(ChannelOption.SO_KEEPALIVE, true);
		Consumer<ServerBootstrap> consumer = onConfigured;
		if (consumer != null) {
			consumer.accept(bootstrap);
		}
		ChannelFuture future = host == null ? bootstrap.bind(port) : bootstrap.bind(host, port);
		future.sync();
	}
public void start ( String host , int port ) throws InterruptedException { ServerBootstrap bootstrap = new ServerBootstrap ( ) ; bossGroup = new NioEventLoopGroup ( ) ; workerGroup = new NioEventLoopGroup ( ) ; bootstrap . group ( bossGroup , workerGroup ) . channel ( NioServerSocketChannel . class ) . childHandler ( new ChannelInitializer < SocketChannel > ( ) { @ Override public void initChannel ( SocketChannel channel ) { channel . pipeline ( ) . addLast ( new PacketDecoder < > ( serializer ) , new LengthFieldPrepender ( 4 ) , new PacketEncoder < > ( serializer ) , new ServerChannelHandler ( ) ) ; Consumer < SocketChannel > consumer = onChannelInitialized ; if ( consumer != null ) { consumer . accept ( channel ) ; } } } ) . option ( ChannelOption . SO_BACKLOG , 128 ) . childOption ( ChannelOption . SO_KEEPALIVE , true ) ; Consumer < ServerBootstrap > consumer = onConfigured ; if ( consumer != null ) { consumer . accept ( bootstrap ) ; } ChannelFuture future = host == null ? bootstrap . bind ( port ) : bootstrap . bind ( host , port ) ; future . sync ( ) ; }
Starts the server synchronously.
Starts the server synchronously .