Example usage for io.netty.channel.socket.nio NioSocketChannel NioSocketChannel

List of usage examples for io.netty.channel.socket.nio NioSocketChannel NioSocketChannel

Introduction

In this page you can find the example usage for io.netty.channel.socket.nio NioSocketChannel NioSocketChannel.

Prototype

public NioSocketChannel(SocketChannel socket) 

Source Link

Document

Create a new instance using the given SocketChannel .

Usage

From source file:diskCacheV111.doors.NettyLineBasedDoorFactory.java

License:Open Source License

@Override
public Cell newCell(Socket socket) throws InvocationTargetException {
    NettyLineBasedDoor door = new NettyLineBasedDoor(parentCellName + "*", args, factory, executor,
            poolManagerHandler, idResolverFactory, spaceDescriptionCache, spaceLookupCache);

    NioSocketChannel channel = new NioSocketChannel(socket.getChannel());

    ChannelPipeline pipeline = channel.pipeline();

    pipeline.addLast("door", door);

    socketGroup.register(channel);//from w ww. j  a va  2  s  . c  om

    return door;
}

From source file:io.nodyn.tcp.TCPWrap.java

License:Apache License

public TCPWrap(NodeProcess process, int fd) throws Exception {
    super(process, false);
    SocketChannel socketChannel = UnsafeTcp.attach(fd);
    NioSocketChannel channel = new NioSocketChannel(socketChannel);
    this.channelFuture = channel.newSucceededFuture();
    channel.pipeline().addLast("emit.afterConnect", new AfterConnectEventHandler(this.process, TCPWrap.this));
    channel.pipeline().addLast("emit.eof", new EOFEventHandler(this.process, TCPWrap.this));
    channel.pipeline().addLast("handle", new UnrefHandler(this));
    process.getEventLoop().getEventLoopGroup().register(channel);
}