List of usage examples for io.netty.channel.socket.nio NioServerSocketChannel NioServerSocketChannel
public NioServerSocketChannel()
From source file:com.linkedin.mitm.proxy.ProxyServer.java
License:Open Source License
/** * Start proxy server/* w w w . j a v a 2 s . c o m*/ * */ public void start() throws InterruptedException { ServerBootstrap serverBootstrap = new ServerBootstrap(); serverBootstrap.group(_acceptorGroup, _upstreamWorkerGroup); serverBootstrap.channelFactory(new ChannelFactory<ServerChannel>() { @Override public ServerChannel newChannel() { return new NioServerSocketChannel(); } }); serverBootstrap.childHandler(new ProxyInitializer(this)); //bind ChannelFuture future = serverBootstrap.bind(_host, _port); //wait for the future future.awaitUninterruptibly(); if (!future.isSuccess()) { future.channel().closeFuture().awaitUninterruptibly(); throw new ChannelException(String.format("Failed to bind to: %s:%d", _host, _port), future.cause()); } else { _allChannels.add(future.channel()); } }
From source file:io.grpc.netty.Utils.java
License:Apache License
private static ChannelFactory<ServerChannel> nioServerChannelFactory() { return new ChannelFactory<ServerChannel>() { @Override/*from w w w . j a va 2 s . c o m*/ public ServerChannel newChannel() { return new NioServerSocketChannel(); } }; }
From source file:org.graylog2.inputs.transports.netty.ServerSocketChannelFactory.java
License:Open Source License
@Override public ServerSocketChannel newChannel() { switch (transportType) { case EPOLL://from w w w .j a v a2 s. c o m return new EpollServerSocketChannel(); case KQUEUE: return new KQueueServerSocketChannel(); case NIO: return new NioServerSocketChannel(); default: throw new IllegalArgumentException("Invalid or unknown Netty transport type " + transportType); } }
From source file:org.jupiter.transport.netty.TcpChannelProvider.java
License:Apache License
@SuppressWarnings("unchecked") @Override// www . j av a 2s . com public T newChannel() { switch (kindChannel) { case ACCEPTOR: switch (typeIO) { case NIO: return (T) new NioServerSocketChannel(); case NATIVE: return (T) new EpollServerSocketChannel(); default: throw new IllegalStateException("invalid type IO: " + typeIO); } case CONNECTOR: switch (typeIO) { case NIO: return (T) new NioSocketChannel(); case NATIVE: return (T) new EpollSocketChannel(); default: throw new IllegalStateException("invalid type IO: " + typeIO); } default: throw new IllegalStateException("invalid kind channel: " + kindChannel); } }