channel.close(); } catch (SocketTimeoutException e) {
private static void registerAcceptedChannel(NioServerSocketChannel parent, SocketChannel acceptedSocket, Thread currentThread) { try { ChannelSink sink = parent.getPipeline().getSink(); ChannelPipeline pipeline = parent.getConfig().getPipelineFactory().getPipeline(); NioWorker worker = parent.workerPool.nextWorker(); worker.register(new NioAcceptedSocketChannel( parent.getFactory(), pipeline, parent, sink , acceptedSocket, worker, currentThread), null); } catch (Exception e) { if (logger.isWarnEnabled()) { logger.warn( "Failed to initialize an accepted socket.", e); } try { acceptedSocket.close(); } catch (IOException e2) { if (logger.isWarnEnabled()) { logger.warn( "Failed to close a partially accepted socket.", e2); } } } }
public void run() { boolean bound = false; boolean registered = false; try { channel.socket.socket().bind(localAddress, channel.getConfig().getBacklog()); bound = true; future.setSuccess(); fireChannelBound(channel, channel.getLocalAddress()); channel.socket.register(selector, SelectionKey.OP_ACCEPT, channel); registered = true; } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } finally { if (!registered && bound) { close(channel, future); } } } }
void close(NioServerSocketChannel channel, ChannelFuture future) { boolean bound = channel.isBound(); try { channel.socket.close(); increaseCancelledKeys(); if (channel.setClosed()) { future.setSuccess(); if (bound) { fireChannelUnbound(channel); } fireChannelClosed(channel); } else { future.setSuccess(); } } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
void close(final NioServerSocketChannel channel, final ChannelFuture closeFuture) { final boolean bound = channel.isBound();
@Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { try { if (channel.setClosed()) { closeFuture.setSuccess(); if (bound) { fireChannelUnbound(channel); } fireChannelClosed(channel); } else { closeFuture.setSuccess(); } } catch (Throwable t) { closeFuture.setFailure(t); fireExceptionCaught(channel, t); } } else { closeFuture.setFailure(future.getCause()); } }
public boolean isBound() { return isOpen() && socket.socket().isBound(); }
public ServerSocketChannel newChannel(ChannelPipeline pipeline) { return new NioServerSocketChannel(this, pipeline, sink, bossPool.nextBoss(), workerPool); }
private static void registerAcceptedChannel(NioServerSocketChannel parent, SocketChannel acceptedSocket, Thread currentThread) { try { ChannelSink sink = parent.getPipeline().getSink(); ChannelPipeline pipeline = parent.getConfig().getPipelineFactory().getPipeline(); NioWorker worker = parent.workerPool.nextWorker(); worker.register(new NioAcceptedSocketChannel( parent.getFactory(), pipeline, parent, sink , acceptedSocket, worker, currentThread), null); } catch (Exception e) { if (logger.isWarnEnabled()) { logger.warn( "Failed to initialize an accepted socket.", e); } try { acceptedSocket.close(); } catch (IOException e2) { if (logger.isWarnEnabled()) { logger.warn( "Failed to close a partially accepted socket.", e2); } } } }
@Override public void run() { boolean bound = false; boolean registered = false; try { channel.socket.socket().bind(localAddress, channel.getConfig().getBacklog()); bound = true; future.setSuccess(); fireChannelBound(channel, channel.getLocalAddress()); channel.socket.register(selector, SelectionKey.OP_ACCEPT, channel); registered = true; } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } finally { if (!registered && bound) { close(channel, future); } } } }
channel.close(); } catch (SocketTimeoutException e) {