Example usage for io.netty.bootstrap ChannelFactory newChannel

List of usage examples for io.netty.bootstrap ChannelFactory newChannel

Introduction

In this page you can find the example usage for io.netty.bootstrap ChannelFactory newChannel.

Prototype

T newChannel();

Source Link

Document

Creates a new channel.

Usage

From source file:io.viewserver.network.netty.ipc.NettyIpcEndpoint.java

License:Apache License

@Override
public ServerBootstrap getServerBootstrap(EventLoopGroup parentGroup, EventLoopGroup childGroup,
        ChannelHandler handler) {//from  www.  j  a v a 2  s.  c om
    ServerBootstrap server = new ServerBootstrap() {
        @Override
        public ServerBootstrap channelFactory(ChannelFactory<? extends ServerChannel> channelFactory) {
            return super.channelFactory(new ChannelFactory<ServerChannel>() {
                @Override
                public ServerChannel newChannel() {
                    try {
                        return channelFactory.newChannel();
                    } catch (Throwable ex) {
                        return null;
                    }
                }
            });
        }
    };
    server.group(parentGroup, childGroup).channel(EpollServerDomainSocketChannel.class).childHandler(handler);
    try {
        server.bind(new DomainSocketAddress(name));
    } catch (Throwable ex) {
        log.warn("Could not listen on IPC socket '" + name + "'");
        return null;
    }
    return server;
}