Package io.netty.bootstrap

Examples of io.netty.bootstrap.ServerBootstrap$ServerBootstrapAcceptor


        return threadingParameters;
    }
     
    protected Channel startServer() {
         
        final ServerBootstrap bootstrap = new ServerBootstrap();
        bootstrap.group(bossGroup, workerGroup)
            .channel(NioServerSocketChannel.class)
            .option(ChannelOption.SO_REUSEADDR, true);
               
        // Set up the idle handler
        IdleStateHandler idleStateHandler =
            new IdleStateHandler(getReadIdleTime(), getWriteIdleTime(), 0);
        // Set up the event pipeline factory.
        servletPipeline =
            new NettyHttpServletPipelineFactory(
                 tlsServerParameters, sessionSupport,
                 threadingParameters.getThreadPoolSize(),
                 maxChunkContentSize,
                 handlerMap, idleStateHandler);
        // Start the servletPipeline's timer
        servletPipeline.start();
        bootstrap.childHandler(servletPipeline);
        InetSocketAddress address = null;
        if (host == null) {
            address = new InetSocketAddress(port);
        } else {
            address = new InetSocketAddress(host, port);
        }
        // Bind and start to accept incoming connections.
        try {
            return bootstrap.bind(address).sync().channel();
        } catch (InterruptedException ex) {
            // do nothing here
            return null;
        }
    }
View Full Code Here


                    .withName("NettyServerTCPWorker")
                    .build();
            wg = workerGroup;
        }
       
        serverBootstrap = new ServerBootstrap();
        serverBootstrap.group(bg, wg).channel(NioServerSocketChannel.class);
        serverBootstrap.childOption(ChannelOption.SO_KEEPALIVE, configuration.isKeepAlive());
        serverBootstrap.childOption(ChannelOption.TCP_NODELAY, configuration.isTcpNoDelay());
        serverBootstrap.option(ChannelOption.SO_REUSEADDR, configuration.isReuseAddress());
        serverBootstrap.childOption(ChannelOption.SO_REUSEADDR, configuration.isReuseAddress());
View Full Code Here

  private final EventLoopGroup eventLoopGroup;

  public BasicServer(RpcConfig rpcMapping, ByteBufAllocator alloc, EventLoopGroup eventLoopGroup) {
    super(rpcMapping);
    this.eventLoopGroup = eventLoopGroup;
    b = new ServerBootstrap() //
        .channel(TransportCheck.getServerSocketChannel()) //
        .option(ChannelOption.SO_BACKLOG, 1000) //
        .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30*1000)
        .option(ChannelOption.TCP_NODELAY, true)
        .option(ChannelOption.SO_REUSEADDR, true)
View Full Code Here

    Channel serverChannel;

    @Override
    public void start() throws InterruptedException {

        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
        .channel(NioServerSocketChannel.class)
        .childHandler(new ChannelInitializer<SocketChannel>() {
            @Override
            public void initChannel(SocketChannel ch) throws Exception {
                ch.pipeline().addLast("decoder",new ProtoDecoder(server));
                ch.pipeline().addLast("encoder",new ProtoEncoder(server));
                ch.pipeline().addLast("handler",new MessageHandler(server,allClientChannels));
            }
        });

        // Bind and start to accept incoming connections.
        ChannelFuture f = b.bind(port).sync();

        serverChannel = f.channel();

        logger.info("Netty server started on port "+port);
View Full Code Here

  public void start() {
    final ErraiServiceConfigurator esc = svc.getConfiguration();
    useSecureWebSocket = ErraiConfigAttribs.SECURE_WEB_SOCKET_SERVER.getBoolean(esc);
    final int port = ErraiConfigAttribs.WEB_SOCKET_PORT.getInt(esc);
    final ServerBootstrap bootstrap = new ServerBootstrap();
    final WebSocketServerHandler webSocketHandler = new WebSocketServerHandler(svc);

    try {
      final NioEventLoopGroup bossGroup = new NioEventLoopGroup();
      final NioEventLoopGroup workerGroup = new NioEventLoopGroup();
      final ChannelFuture channelFuture = bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
              .childHandler(new ChannelInitializer() {
                @Override
                protected void initChannel(Channel ch) throws Exception {
                  if (useSecureWebSocket) {
                    final SslHandler sslHandler = SslHandlerFactory.buildSslHandler(esc);
View Full Code Here

@SuppressWarnings("rawtypes")
public abstract class ConnectionBasedServerBuilder<I, O, B extends ConnectionBasedServerBuilder>
        extends AbstractServerBuilder<I,O, ServerBootstrap, ServerChannel, B, RxServer<I, O>> {

    protected ConnectionBasedServerBuilder(int port, ConnectionHandler<I, O> connectionHandler) {
        this(port, connectionHandler, new ServerBootstrap());
    }
View Full Code Here

    // Configure the server.
    bossGroup = new OioEventLoopGroup();
    workerGroup = new OioEventLoopGroup();

    ServerBootstrap bootstrap = new ServerBootstrap();
    bootstrap.group(bossGroup, workerGroup)
        .channel(OioServerSocketChannel.class)
        .option(ChannelOption.SO_BACKLOG, 100)
        .option(ChannelOption.SO_RCVBUF, 1500)
        .childHandler(new FileServerChannelInitializer(pResolver));
    // Start the server.
    channelFuture = bootstrap.bind(addr);
    try {
      // Get the address we bound to.
      InetSocketAddress boundAddress =
        ((InetSocketAddress) channelFuture.sync().channel().localAddress());
      this.port = boundAddress.getPort();
View Full Code Here

    }

    private void startServer() throws Exception {
        this.bossGroup = new NioEventLoopGroup();
        this.workerGroup = new NioEventLoopGroup();
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .childHandler(new WebSocketServerInitializer());

        this.serverChannel = b.bind(this.port).sync().channel();

        log.info("Web socket server started at port {}.", port);
    }
View Full Code Here

        bossGroup = new NioEventLoopGroup();
        workerGroup = new NioEventLoopGroup();
        channelGroup = new DefaultChannelGroup("mongodb-channels", workerGroup.next());

        try {
            ServerBootstrap bootstrap = new ServerBootstrap();
            bootstrap//
                    .group(bossGroup, workerGroup)//
                    .channel(NioServerSocketChannel.class)//
                    .option(ChannelOption.SO_BACKLOG, 100)//
                    .localAddress(socketAddress)//
                    .childOption(ChannelOption.TCP_NODELAY, true)//
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        public void initChannel(SocketChannel ch) throws Exception {
                            ch.pipeline().addLast(new MongoWireEncoder());
                            ch.pipeline().addLast(new MongoWireProtocolHandler());
                            ch.pipeline().addLast(new MongoDatabaseHandler(backend, channelGroup));
                            ch.pipeline().addLast(new MongoExceptionHandler());
                        }
                    });

            channel = bootstrap.bind().syncUninterruptibly().channel();

            log.info("started {}", this);
        } catch (RuntimeException e) {
            shutdownNow();
            throw e;
View Full Code Here

     */
    public NettyServer(LocalHost localHost, String address, int port, ConnectListener connectListener) {
        bossGroup = new NioEventLoopGroup();
        workerGroup = new NioEventLoopGroup();

        bootstrap = new ServerBootstrap();
        bootstrap.group(bossGroup, workerGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new NettyChannelInitializer(localHost, connectListener))
                .childOption(ChannelOption.TCP_NODELAY, true)
                .childOption(ChannelOption.SO_KEEPALIVE, true)
View Full Code Here

TOP

Related Classes of io.netty.bootstrap.ServerBootstrap$ServerBootstrapAcceptor

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.