KQueueSocketChannel(Channel parent, BsdSocket fd, InetSocketAddress remoteAddress) { super(parent, fd, remoteAddress); config = new KQueueSocketChannelConfig(this); }
KQueueSocketChannelConfig(KQueueSocketChannel channel) { super(channel); if (PlatformDependent.canEnableTcpNoDelayByDefault()) { setTcpNoDelay(true); } calculateMaxBytesPerGatheringWrite(); }
@Override public Map<ChannelOption<?>, Object> getOptions() { return getOptions( super.getOptions(), SO_RCVBUF, SO_SNDBUF, TCP_NODELAY, SO_KEEPALIVE, SO_REUSEADDR, SO_LINGER, IP_TOS, ALLOW_HALF_CLOSURE, SO_SNDLOWAT, TCP_NOPUSH); }
private void calculateMaxBytesPerGatheringWrite() { // Multiply by 2 to give some extra space in case the OS can process write data faster than we can provide. int newSendBufferSize = getSendBufferSize() << 1; if (newSendBufferSize > 0) { setMaxBytesPerGatheringWrite(getSendBufferSize() << 1); } } }
public <T> T getOption(ChannelOption<T> option) { if (option == SO_RCVBUF) { return (T) Integer.valueOf(getReceiveBufferSize()); return (T) Integer.valueOf(getSendBufferSize()); return (T) Boolean.valueOf(isTcpNoDelay()); return (T) Boolean.valueOf(isKeepAlive()); return (T) Boolean.valueOf(isReuseAddress()); return (T) Integer.valueOf(getSoLinger()); return (T) Integer.valueOf(getTrafficClass()); return (T) Boolean.valueOf(isAllowHalfClosure()); return (T) Integer.valueOf(getSndLowAt()); return (T) Boolean.valueOf(isTcpNoPush());
@Override public KQueueSocketChannelConfig setSendBufferSize(int sendBufferSize) { try { ((KQueueSocketChannel) channel).socket.setSendBufferSize(sendBufferSize); calculateMaxBytesPerGatheringWrite(); return this; } catch (IOException e) { throw new ChannelException(e); } }
@Override protected Executor prepareToClose() { try { // Check isOpen() first as otherwise it will throw a RuntimeException // when call getSoLinger() as the fd is not valid anymore. if (isOpen() && config().getSoLinger() > 0) { // We need to cancel this key of the channel so we may not end up in a eventloop spin // because we try to read or write until the actual close happens which may be later due // SO_LINGER handling. // See https://github.com/netty/netty/issues/4449 ((KQueueEventLoop) eventLoop()).remove(KQueueSocketChannel.this); return GlobalEventExecutor.INSTANCE; } } catch (Throwable ignore) { // Ignore the error as the underlying channel may be closed in the meantime and so // getSoLinger() may produce an exception. In this case we just return null. // See https://github.com/netty/netty/issues/4449 } return null; } }
public <T> T getOption(ChannelOption<T> option) { if (option == SO_RCVBUF) { return (T) Integer.valueOf(getReceiveBufferSize()); return (T) Integer.valueOf(getSendBufferSize()); return (T) Boolean.valueOf(isTcpNoDelay()); return (T) Boolean.valueOf(isKeepAlive()); return (T) Boolean.valueOf(isReuseAddress()); return (T) Integer.valueOf(getSoLinger()); return (T) Integer.valueOf(getTrafficClass()); return (T) Boolean.valueOf(isAllowHalfClosure()); return (T) Integer.valueOf(getSndLowAt()); return (T) Boolean.valueOf(isTcpNoPush());
private void calculateMaxBytesPerGatheringWrite() { // Multiply by 2 to give some extra space in case the OS can process write data faster than we can provide. int newSendBufferSize = getSendBufferSize() << 1; if (newSendBufferSize > 0) { setMaxBytesPerGatheringWrite(getSendBufferSize() << 1); } } }
@Override public KQueueSocketChannelConfig setSendBufferSize(int sendBufferSize) { try { channel.socket.setSendBufferSize(sendBufferSize); calculateMaxBytesPerGatheringWrite(); return this; } catch (IOException e) { throw new ChannelException(e); } }
@Override protected Executor prepareToClose() { try { // Check isOpen() first as otherwise it will throw a RuntimeException // when call getSoLinger() as the fd is not valid anymore. if (isOpen() && config().getSoLinger() > 0) { // We need to cancel this key of the channel so we may not end up in a eventloop spin // because we try to read or write until the actual close happens which may be later due // SO_LINGER handling. // See https://github.com/netty/netty/issues/4449 ((KQueueEventLoop) eventLoop()).remove(KQueueSocketChannel.this); return GlobalEventExecutor.INSTANCE; } } catch (Throwable ignore) { // Ignore the error as the underlying channel may be closed in the meantime and so // getSoLinger() may produce an exception. In this case we just return null. // See https://github.com/netty/netty/issues/4449 } return null; } }
public <T> T getOption(ChannelOption<T> option) { if (option == SO_RCVBUF) { return (T) Integer.valueOf(getReceiveBufferSize()); return (T) Integer.valueOf(getSendBufferSize()); return (T) Boolean.valueOf(isTcpNoDelay()); return (T) Boolean.valueOf(isKeepAlive()); return (T) Boolean.valueOf(isReuseAddress()); return (T) Integer.valueOf(getSoLinger()); return (T) Integer.valueOf(getTrafficClass()); return (T) Boolean.valueOf(isAllowHalfClosure()); return (T) Integer.valueOf(getSndLowAt()); return (T) Boolean.valueOf(isTcpNoPush());
private void calculateMaxBytesPerGatheringWrite() { // Multiply by 2 to give some extra space in case the OS can process write data faster than we can provide. int newSendBufferSize = getSendBufferSize() << 1; if (newSendBufferSize > 0) { setMaxBytesPerGatheringWrite(getSendBufferSize() << 1); } } }
KQueueSocketChannelConfig(KQueueSocketChannel channel) { super(channel); this.channel = channel; if (PlatformDependent.canEnableTcpNoDelayByDefault()) { setTcpNoDelay(true); } calculateMaxBytesPerGatheringWrite(); }
KQueueSocketChannel(Channel parent, BsdSocket fd, InetSocketAddress remoteAddress) { super(parent, fd, remoteAddress); config = new KQueueSocketChannelConfig(this); }
@Override public Map<ChannelOption<?>, Object> getOptions() { return getOptions( super.getOptions(), SO_RCVBUF, SO_SNDBUF, TCP_NODELAY, SO_KEEPALIVE, SO_REUSEADDR, SO_LINGER, IP_TOS, ALLOW_HALF_CLOSURE, SO_SNDLOWAT, TCP_NOPUSH); }
@Override public KQueueSocketChannelConfig setSendBufferSize(int sendBufferSize) { try { ((KQueueSocketChannel) channel).socket.setSendBufferSize(sendBufferSize); calculateMaxBytesPerGatheringWrite(); return this; } catch (IOException e) { throw new ChannelException(e); } }
@Override protected Executor prepareToClose() { try { // Check isOpen() first as otherwise it will throw a RuntimeException // when call getSoLinger() as the fd is not valid anymore. if (isOpen() && config().getSoLinger() > 0) { // We need to cancel this key of the channel so we may not end up in a eventloop spin // because we try to read or write until the actual close happens which may be later due // SO_LINGER handling. // See https://github.com/netty/netty/issues/4449 ((KQueueEventLoop) eventLoop()).remove(KQueueSocketChannel.this); return GlobalEventExecutor.INSTANCE; } } catch (Throwable ignore) { // Ignore the error as the underlying channel may be closed in the meantime and so // getSoLinger() may produce an exception. In this case we just return null. // See https://github.com/netty/netty/issues/4449 } return null; } }
public <T> T getOption(ChannelOption<T> option) { if (option == SO_RCVBUF) { return (T) Integer.valueOf(getReceiveBufferSize()); return (T) Integer.valueOf(getSendBufferSize()); return (T) Boolean.valueOf(isTcpNoDelay()); return (T) Boolean.valueOf(isKeepAlive()); return (T) Boolean.valueOf(isReuseAddress()); return (T) Integer.valueOf(getSoLinger()); return (T) Integer.valueOf(getTrafficClass()); return (T) Boolean.valueOf(isAllowHalfClosure()); return (T) Integer.valueOf(getSndLowAt()); return (T) Boolean.valueOf(isTcpNoPush());
private void calculateMaxBytesPerGatheringWrite() { // Multiply by 2 to give some extra space in case the OS can process write data faster than we can provide. int newSendBufferSize = getSendBufferSize() << 1; if (newSendBufferSize > 0) { setMaxBytesPerGatheringWrite(getSendBufferSize() << 1); } } }