Java 类io.netty.channel.socket.ServerSocketChannel 实例源码

项目:util4j    文件:AbstractNettyServer.java   
/**
 * 启动端口绑定
 * @param local
 * @return
 */
protected final boolean bind(InetSocketAddress local)
{
    boolean isBind=false;
    try {
        log.debug(getName()+"端口绑定中……"+local.toString());
        ChannelFuture cf=doBind(local);
        isBind=cf.channel()!=null && cf.channel().isActive();
        if(isBind)
        {
            log.debug(getName()+"端口绑定成功!"+cf.channel());
            serverCahnel=(ServerSocketChannel) cf.channel();
        }else
        {
            log.debug(getName()+"端口绑定失败!"+cf.channel());
        }
    } catch (Exception e) {
        log.error(e.getMessage(),e);
        throw e;
    }
    return isBind;
}
项目:Diorite-old    文件:ServerConnection.java   
@Override
public void init(final InetAddress address, final int port, final boolean useEpoll)
{
    final Class<? extends ServerSocketChannel> socketChannelClass;
    final LazyValue<? extends EventLoopGroup> lazyInit;
    if ((Epoll.isAvailable()) && useEpoll)
    {
        socketChannelClass = EpollServerSocketChannel.class;
        lazyInit = this.epollEventLoopGroupLazyValue;
        CoreMain.debug("[Netty] Using epoll channel type");
    }
    else
    {
        socketChannelClass = NioServerSocketChannel.class;
        lazyInit = this.nioEventLoopGroupLazyValue;
        CoreMain.debug("[Netty] Using default channel type");
    }
    this.channelFuture = new ServerBootstrap().channel(socketChannelClass).childHandler(new ServerConnectionChannel(this)).group(lazyInit.get()).localAddress(address, port).bind().syncUninterruptibly();
}
项目:x-pipe    文件:DefaultRedisKeeperServer.java   
protected void startServer() throws InterruptedException {

      ServerBootstrap b = new ServerBootstrap();
      b.group(bossGroup, workerGroup)
       .channel(NioServerSocketChannel.class)
       .handler(new LoggingHandler(LogLevel.INFO))
       .childHandler(new ChannelInitializer<SocketChannel>() {
           @Override
           public void initChannel(SocketChannel ch) throws Exception {
               ChannelPipeline p = ch.pipeline();
               p.addLast(new LoggingHandler(LogLevel.DEBUG));
               p.addLast(new NettySimpleMessageHandler());
               p.addLast(new NettyMasterHandler(DefaultRedisKeeperServer.this, new CommandHandlerManager(), keeperConfig.getTrafficReportIntervalMillis()));
           }
       });
      serverSocketChannel = (ServerSocketChannel) b.bind(currentKeeperMeta.getPort()).sync().channel();
  }
项目:asyncrmi    文件:ClassLoaderServer.java   
public ClassLoaderServer(ClassLoader classLoader) throws UnknownHostException, InterruptedException {
    String codeBase = System.getProperty("java.rmi.server.codebase", null);
    if (codeBase == null || codeBase.matches("[0-9]+")) {
        Transport transport = Modules.getInstance().getTransport();
        int port = (codeBase == null) ? 0 : Integer.valueOf(codeBase);
        httpChannel = ClassLoaderServer.run(transport.getAcceptGroup(), transport.getWorkerGroup(), port, classLoader);
        InetSocketAddress inetSocketAddress = ((ServerSocketChannel) httpChannel).localAddress();
        port = inetSocketAddress.getPort();
        String hostName = Modules.getInstance().getConfiguration().getServerHostName();
        if(hostName == null){
            hostName = InetAddress.getLocalHost().getHostName();
        }

        System.setProperty("java.rmi.server.codebase", "http://" + hostName + ":" + port + "/");
        LoaderHandler.loadCodeBaseProperty();
        logger.info("Embedded HTTP server run at {} java.rmi.server.codebase is set to {} ", inetSocketAddress, System.getProperty("java.rmi.server.codebase"));
    } else {
        httpChannel = null;
    }
}
项目:TakinRPC    文件:RpcServer.java   
<T extends ServerSocketChannel> RpcServer(EventLoopGroup eventLoopGroup, EventExecutorGroup eventExecutor, Class<T> channel, SocketAddress address) {
    this.address = address;
    this.allChannels = new DefaultChannelGroup(eventLoopGroup.next());
    this.handler = new ServerHandler(allChannels);
    this.bootstrap = new ServerBootstrap();
    bootstrap.channel(channel);
    bootstrap.childHandler(new ServerInitializer(eventExecutor, handler));
    bootstrap.group(eventLoopGroup);
    bootstrap.option(ChannelOption.TCP_NODELAY, true);
}
项目:QDrill    文件:TransportCheck.java   
public static Class<? extends ServerSocketChannel> getServerSocketChannel(){
  if(SUPPORTS_EPOLL){
    return EpollServerSocketChannel.class;
  }else{
    return NioServerSocketChannel.class;
  }
}
项目:dremio-oss    文件:TransportCheck.java   
public static Class<? extends ServerSocketChannel> getServerSocketChannel(){
  if(SUPPORTS_EPOLL){
    return EpollServerSocketChannel.class;
  }else{
    return NioServerSocketChannel.class;
  }
}
项目:incubator-pulsar    文件:EventLoopUtil.java   
public static Class<? extends ServerSocketChannel> getServerSocketChannelClass(EventLoopGroup eventLoopGroup) {
    if (eventLoopGroup instanceof EpollEventLoopGroup) {
        return EpollServerSocketChannel.class;
    } else {
        return NioServerSocketChannel.class;
    }
}
项目:reactor-netty    文件:NettyContext.java   
/**
 * Return remote address if remote channel {@link NettyContext} otherwise local
 * address if server selector channel.
 *
 * @return remote or local {@link InetSocketAddress}
 */
default InetSocketAddress address(){
    Channel c = channel();
    if (c instanceof SocketChannel) {
        return ((SocketChannel) c).remoteAddress();
    }
    if (c instanceof ServerSocketChannel) {
        return ((ServerSocketChannel) c).localAddress();
    }
    if (c instanceof DatagramChannel) {
        InetSocketAddress a = ((DatagramChannel) c).remoteAddress();
        return a != null ? a : ((DatagramChannel)c ).localAddress();
    }
    throw new IllegalStateException("Does not have an InetSocketAddress");
}
项目:drill    文件:TransportCheck.java   
public static Class<? extends ServerSocketChannel> getServerSocketChannel(){
  if(SUPPORTS_EPOLL){
    return EpollServerSocketChannel.class;
  }else{
    return NioServerSocketChannel.class;
  }
}
项目:Neddy    文件:HttpServer.java   
HttpServer(Supplier<EventLoopGroup> eventLoopFactory,
        ServerChannelFactory<ServerSocketChannel> channelFactory,
        ChannelInitializer channelInitializer,
        HttpEventBus eventBus) {
    super(eventLoopFactory, channelFactory, channelInitializer);
    this.eventBus = eventBus;
}
项目:Neddy    文件:Server.java   
public Server(Supplier<EventLoopGroup> eventLoopFactory,
        ServerChannelFactory<ServerSocketChannel> channelFactory,
        ChannelInitializer channelInitializer) {
    this.bossGroup = eventLoopFactory.get();
    this.workerGroup = eventLoopFactory.get();

    serverBootstrap = new ServerBootstrap()
            .group(bossGroup, workerGroup)
            .channelFactory(channelFactory)
            .childHandler(channelInitializer);
}
项目:netty-xnio-transport    文件:AbstractXnioSocketChannel.java   
@Override
protected boolean isCompatible(EventLoop loop) {
    if (!(loop instanceof XnioEventLoop)) {
        return false;
    }
    ServerSocketChannel parent = parent();
    if (parent != null) {
        // if this channel has a parent we need to ensure that both EventLoopGroups are the same for XNIO
        // to be sure it uses a Thread from the correct Worker.
        if (parent.eventLoop().parent() != loop.parent()) {
            return false;
        }
    }
    return true;
}
项目:CloudNet    文件:NetworkUtils.java   
public static Class<? extends ServerSocketChannel> serverSocketChannel()
{
    return EPOLL ? EpollServerSocketChannel.class : NioServerSocketChannel.class;
}
项目:DecompiledMinecraft    文件:NetworkSystem.java   
/**
 * Adds a channel that listens on publicly accessible network ports
 */
public void addLanEndpoint(InetAddress address, int port) throws IOException
{
    synchronized (this.endpoints)
    {
        Class <? extends ServerSocketChannel > oclass;
        LazyLoadBase <? extends EventLoopGroup > lazyloadbase;

        if (Epoll.isAvailable() && this.mcServer.func_181035_ah())
        {
            oclass = EpollServerSocketChannel.class;
            lazyloadbase = field_181141_b;
            logger.info("Using epoll channel type");
        }
        else
        {
            oclass = NioServerSocketChannel.class;
            lazyloadbase = eventLoops;
            logger.info("Using default channel type");
        }

        this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                try
                {
                    p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
                }
                catch (ChannelException var3)
                {
                    ;
                }

                p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"legacy_query", (ChannelHandler)(new PingResponseHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.CLIENTBOUND)));
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
                networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager));
            }
        }).group((EventLoopGroup)lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
    }
}
项目:DecompiledMinecraft    文件:NetworkSystem.java   
/**
 * Adds a channel that listens on publicly accessible network ports
 */
public void addLanEndpoint(InetAddress address, int port) throws IOException
{
    synchronized (this.endpoints)
    {
        Class <? extends ServerSocketChannel > oclass;
        LazyLoadBase <? extends EventLoopGroup > lazyloadbase;

        if (Epoll.isAvailable() && this.mcServer.func_181035_ah())
        {
            oclass = EpollServerSocketChannel.class;
            lazyloadbase = field_181141_b;
            logger.info("Using epoll channel type");
        }
        else
        {
            oclass = NioServerSocketChannel.class;
            lazyloadbase = eventLoops;
            logger.info("Using default channel type");
        }

        this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                try
                {
                    p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
                }
                catch (ChannelException var3)
                {
                    ;
                }

                p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"legacy_query", (ChannelHandler)(new PingResponseHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.CLIENTBOUND)));
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
                networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager));
            }
        }).group((EventLoopGroup)lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
    }
}
项目:BaseClient    文件:NetworkSystem.java   
/**
 * Adds a channel that listens on publicly accessible network ports
 */
public void addLanEndpoint(InetAddress address, int port) throws IOException
{
    synchronized (this.endpoints)
    {
        Class <? extends ServerSocketChannel > oclass;
        LazyLoadBase <? extends EventLoopGroup > lazyloadbase;

        if (Epoll.isAvailable() && this.mcServer.func_181035_ah())
        {
            oclass = EpollServerSocketChannel.class;
            lazyloadbase = field_181141_b;
            logger.info("Using epoll channel type");
        }
        else
        {
            oclass = NioServerSocketChannel.class;
            lazyloadbase = eventLoops;
            logger.info("Using default channel type");
        }

        this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                try
                {
                    p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
                }
                catch (ChannelException var3)
                {
                    ;
                }

                p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"legacy_query", (ChannelHandler)(new PingResponseHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.CLIENTBOUND)));
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
                networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager));
            }
        }).group((EventLoopGroup)lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
    }
}
项目:BaseClient    文件:NetworkSystem.java   
/**
 * Adds a channel that listens on publicly accessible network ports
 */
public void addLanEndpoint(InetAddress address, int port) throws IOException
{
    synchronized (this.endpoints)
    {
        Class <? extends ServerSocketChannel > oclass;
        LazyLoadBase <? extends EventLoopGroup > lazyloadbase;

        if (Epoll.isAvailable() && this.mcServer.func_181035_ah())
        {
            oclass = EpollServerSocketChannel.class;
            lazyloadbase = field_181141_b;
            logger.info("Using epoll channel type");
        }
        else
        {
            oclass = NioServerSocketChannel.class;
            lazyloadbase = eventLoops;
            logger.info("Using default channel type");
        }

        this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                try
                {
                    p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
                }
                catch (ChannelException var3)
                {
                    ;
                }

                p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"legacy_query", (ChannelHandler)(new PingResponseHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.CLIENTBOUND)));
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
                networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager));
            }
        }).group((EventLoopGroup)lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
    }
}
项目:Backmemed    文件:NetworkSystem.java   
/**
 * Adds a channel that listens on publicly accessible network ports
 */
public void addLanEndpoint(InetAddress address, int port) throws IOException
{
    synchronized (this.endpoints)
    {
        Class <? extends ServerSocketChannel > oclass;
        LazyLoadBase <? extends EventLoopGroup > lazyloadbase;

        if (Epoll.isAvailable() && this.mcServer.shouldUseNativeTransport())
        {
            oclass = EpollServerSocketChannel.class;
            lazyloadbase = SERVER_EPOLL_EVENTLOOP;
            LOGGER.info("Using epoll channel type");
        }
        else
        {
            oclass = NioServerSocketChannel.class;
            lazyloadbase = SERVER_NIO_EVENTLOOP;
            LOGGER.info("Using default channel type");
        }

        this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                try
                {
                    p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
                }
                catch (ChannelException var3)
                {
                    ;
                }

                p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"legacy_query", (ChannelHandler)(new LegacyPingHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new NettyVarint21FrameDecoder())).addLast((String)"decoder", (ChannelHandler)(new NettyPacketDecoder(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new NettyVarint21FrameEncoder())).addLast((String)"encoder", (ChannelHandler)(new NettyPacketEncoder(EnumPacketDirection.CLIENTBOUND)));
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
                networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager));
            }
        }).group((EventLoopGroup)lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
    }
}
项目:CustomWorldGen    文件:NetworkSystem.java   
/**
 * Adds a channel that listens on publicly accessible network ports
 */
public void addLanEndpoint(InetAddress address, int port) throws IOException
{
    synchronized (this.endpoints)
    {
        Class <? extends ServerSocketChannel > oclass;
        LazyLoadBase <? extends EventLoopGroup > lazyloadbase;

        if (Epoll.isAvailable() && this.mcServer.shouldUseNativeTransport())
        {
            oclass = EpollServerSocketChannel.class;
            lazyloadbase = SERVER_EPOLL_EVENTLOOP;
            LOGGER.info("Using epoll channel type");
        }
        else
        {
            oclass = NioServerSocketChannel.class;
            lazyloadbase = SERVER_NIO_EVENTLOOP;
            LOGGER.info("Using default channel type");
        }

        this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                try
                {
                    p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
                }
                catch (ChannelException var3)
                {
                    ;
                }

                p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.READ_TIMEOUT))).addLast((String)"legacy_query", (ChannelHandler)(new LegacyPingHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new NettyVarint21FrameDecoder())).addLast((String)"decoder", (ChannelHandler)(new NettyPacketDecoder(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new NettyVarint21FrameEncoder())).addLast((String)"encoder", (ChannelHandler)(new NettyPacketEncoder(EnumPacketDirection.CLIENTBOUND)));
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
                networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager));
            }
        }).group((EventLoopGroup)lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
    }
}
项目:tenorite    文件:NetConfig.java   
private Class<? extends ServerSocketChannel> socketChannelClass() {
    return USE_EPOLL ? EpollServerSocketChannel.class : NioServerSocketChannel.class;
}
项目:reactor-netty    文件:ServerContextHandler.java   
@Override
public InetSocketAddress address() {
    return ((ServerSocketChannel) f.channel()).localAddress();
}
项目:netty4.0.27Learn    文件:OioSocketChannel.java   
@Override
public ServerSocketChannel parent() {
    return (ServerSocketChannel) super.parent();
}
项目:netty4.0.27Learn    文件:DefaultOioServerSocketChannelConfig.java   
@Deprecated
public DefaultOioServerSocketChannelConfig(ServerSocketChannel channel, ServerSocket javaSocket) {
    super(channel, javaSocket);
}
项目:netty4.0.27Learn    文件:NioSocketChannel.java   
@Override
public ServerSocketChannel parent() {
    return (ServerSocketChannel) super.parent();
}
项目:netty4.0.27Learn    文件:NioEventLoopTest.java   
@Override
protected Class<? extends ServerSocketChannel> newChannel() {
    return NioServerSocketChannel.class;
}
项目:netty4.0.27Learn    文件:EpollSocketChannel.java   
@Override
public ServerSocketChannel parent() {
    return (ServerSocketChannel) super.parent();
}
项目:scalecube    文件:BootstrapFactory.java   
private Class<? extends ServerSocketChannel> serverChannelClass() {
  return isEpollSupported() ? EpollServerSocketChannel.class : NioServerSocketChannel.class;
}
项目:TtorrentAndroid    文件:PeerServer.java   
@Nonnull
public InetSocketAddress getLocalAddress() {
    ServerSocketChannel channel = (ServerSocketChannel) future.channel();
    return channel.localAddress();
}
项目:netty4study    文件:OioSocketChannel.java   
@Override
public ServerSocketChannel parent() {
    return (ServerSocketChannel) super.parent();
}
项目:netty4study    文件:DefaultOioServerSocketChannelConfig.java   
public DefaultOioServerSocketChannelConfig(ServerSocketChannel channel, ServerSocket javaSocket) {
    super(channel, javaSocket);
}
项目:netty4study    文件:NioSocketChannel.java   
@Override
public ServerSocketChannel parent() {
    return (ServerSocketChannel) super.parent();
}
项目:netty4study    文件:NioEventLoopTest.java   
@Override
protected Class<? extends ServerSocketChannel> newChannel() {
    return NioServerSocketChannel.class;
}
项目:ExpandedRailsMod    文件:NetworkSystem.java   
/**
 * Adds a channel that listens on publicly accessible network ports
 */
public void addLanEndpoint(InetAddress address, int port) throws IOException
{
    synchronized (this.endpoints)
    {
        Class <? extends ServerSocketChannel > oclass;
        LazyLoadBase <? extends EventLoopGroup > lazyloadbase;

        if (Epoll.isAvailable() && this.mcServer.shouldUseNativeTransport())
        {
            oclass = EpollServerSocketChannel.class;
            lazyloadbase = SERVER_EPOLL_EVENTLOOP;
            LOGGER.info("Using epoll channel type");
        }
        else
        {
            oclass = NioServerSocketChannel.class;
            lazyloadbase = SERVER_NIO_EVENTLOOP;
            LOGGER.info("Using default channel type");
        }

        this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                try
                {
                    p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
                }
                catch (ChannelException var3)
                {
                    ;
                }

                p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.READ_TIMEOUT))).addLast((String)"legacy_query", (ChannelHandler)(new LegacyPingHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new NettyVarint21FrameDecoder())).addLast((String)"decoder", (ChannelHandler)(new NettyPacketDecoder(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new NettyVarint21FrameEncoder())).addLast((String)"encoder", (ChannelHandler)(new NettyPacketEncoder(EnumPacketDirection.CLIENTBOUND)));
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
                networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager));
            }
        }).group((EventLoopGroup)lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
    }
}
项目:netty-netty-5.0.0.Alpha1    文件:OioSocketChannel.java   
@Override
public ServerSocketChannel parent() {
    return (ServerSocketChannel) super.parent();
}
项目:netty-netty-5.0.0.Alpha1    文件:DefaultOioServerSocketChannelConfig.java   
public DefaultOioServerSocketChannelConfig(ServerSocketChannel channel, ServerSocket javaSocket) {
    super(channel, javaSocket);
}
项目:netty-netty-5.0.0.Alpha1    文件:NioSocketChannel.java   
@Override
public ServerSocketChannel parent() {
    return (ServerSocketChannel) super.parent();
}
项目:netty-netty-5.0.0.Alpha1    文件:NioEventLoopTest.java   
@Override
protected Class<? extends ServerSocketChannel> newChannel() {
    return NioServerSocketChannel.class;
}
项目:socketio    文件:DefaultServerBootstrapFactory.java   
private Class<? extends ServerSocketChannel> serverChannelClass() {
  return isEpollSupported() ? EpollServerSocketChannel.class : NioServerSocketChannel.class;
}
项目:netty-xnio-transport    文件:AbstractXnioSocketChannel.java   
@Override
public ServerSocketChannel parent() {
    return (ServerSocketChannel) super.parent();
}