private ServerSocketChannel jdkChannel() { return ((NioServerSocketChannel) channel).javaChannel(); } }
private ServerSocketChannel jdkChannel() { return ((NioServerSocketChannel) channel).javaChannel(); } }
@Override protected void doClose() throws Exception { javaChannel().close(); }
private ServerSocketChannel jdkChannel() { return ((NioServerSocketChannel) channel).javaChannel(); } }
@Override protected void doClose() throws Exception { javaChannel().close(); }
@Override protected SocketAddress localAddress0() { return SocketUtils.localSocketAddress(javaChannel().socket()); }
/** * Create a new instance using the given {@link ServerSocketChannel}. */ public NioServerSocketChannel(ServerSocketChannel channel) { super(null, channel, SelectionKey.OP_ACCEPT); config = new NioServerSocketChannelConfig(this, javaChannel().socket()); }
@Override protected void doClose() throws Exception { javaChannel().close(); }
@Override public boolean isActive() { return javaChannel().socket().isBound(); }
/** * Create a new instance using the given {@link ServerSocketChannel}. */ public NioServerSocketChannel(ServerSocketChannel channel) { super(null, channel, SelectionKey.OP_ACCEPT); config = new NioServerSocketChannelConfig(this, javaChannel().socket()); }
@Override protected SocketAddress localAddress0() { return SocketUtils.localSocketAddress(javaChannel().socket()); }
@Override public boolean isActive() { return javaChannel().socket().isBound(); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { if (PlatformDependent.javaVersion() >= 7) { javaChannel().bind(localAddress, config.getBacklog()); } else { javaChannel().socket().bind(localAddress, config.getBacklog()); } }
/** * Create a new instance using the given {@link ServerSocketChannel}. */ public NioServerSocketChannel(ServerSocketChannel channel) { super(null, channel, SelectionKey.OP_ACCEPT); config = new NioServerSocketChannelConfig(this, javaChannel().socket()); }
@Override protected SocketAddress localAddress0() { return SocketUtils.localSocketAddress(javaChannel().socket()); }
@Override public boolean isActive() { return javaChannel().socket().isBound(); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { if (PlatformDependent.javaVersion() >= 7) { javaChannel().bind(localAddress, config.getBacklog()); } else { javaChannel().socket().bind(localAddress, config.getBacklog()); } }
@Override protected void doBind(SocketAddress localAddress) throws Exception { if (PlatformDependent.javaVersion() >= 7) { javaChannel().bind(localAddress, config.getBacklog()); } else { javaChannel().socket().bind(localAddress, config.getBacklog()); } }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }