@Override public ChannelFuture leaveGroup( InetSocketAddress multicastAddress, NetworkInterface networkInterface) { return leaveGroup(multicastAddress, networkInterface, newPromise()); }
/** * Block the given sourceToBlock address for the given multicastAddress * */ @Override public ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock) { return block(multicastAddress, sourceToBlock, newPromise()); }
@Override public DatagramChannelConfig setNetworkInterface(NetworkInterface networkInterface) { setOption0(IP_MULTICAST_IF, networkInterface); return this; }
@Override public ChannelFuture joinGroup( InetSocketAddress multicastAddress, NetworkInterface networkInterface) { return joinGroup(multicastAddress, networkInterface, newPromise()); }
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); } }
/** * 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()); }
/** * Create a new instance using the given {@link SelectorProvider} * which will use the Operation Systems default {@link InternetProtocolFamily}. */ public NioDatagramChannel(SelectorProvider provider) { this(newSocket(provider)); }
/** * Create a new instance */ public NioServerSocketChannel() { this(newSocket(DEFAULT_SELECTOR_PROVIDER)); }
/** * Create a new instance using the given {@link SelectorProvider}. */ public NioSocketChannel(SelectorProvider provider) { this(newSocket(provider)); }
/** * Create a new instance from the given {@link DatagramChannel}. */ public NioDatagramChannel(DatagramChannel socket) { super(null, socket, SelectionKey.OP_READ); config = new NioDatagramChannelConfig(this, socket); }
private void adjustMaxBytesPerGatheringWrite(int attempted, int written, int oldMaxBytesPerGatheringWrite) { // By default we track the SO_SNDBUF when ever it is explicitly set. However some OSes may dynamically change // SO_SNDBUF (and other characteristics that determine how much data can be written at once) so we should try // make a best effort to adjust as OS behavior changes. if (attempted == written) { if (attempted << 1 > oldMaxBytesPerGatheringWrite) { ((NioSocketChannelConfig) config).setMaxBytesPerGatheringWrite(attempted << 1); } } else if (attempted > MAX_BYTES_PER_GATHERING_WRITE_ATTEMPTED_LOW_THRESHOLD && written < attempted >>> 1) { ((NioSocketChannelConfig) config).setMaxBytesPerGatheringWrite(attempted >>> 1); } }
/** * Returns a {@link ChannelOption} for the given {@link java.net.SocketOption}. */ public static <T> ChannelOption<T> of(java.net.SocketOption<T> option) { return new NioChannelOption<T>(option); }
@Override public ChannelFuture leaveGroup( InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) { return leaveGroup(multicastAddress, networkInterface, source, newPromise()); }
@Override public ChannelFuture joinGroup( InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) { return joinGroup(multicastAddress, networkInterface, source, newPromise()); }
/** * Block the given sourceToBlock address for the given multicastAddress on the given networkInterface */ @Override public ChannelFuture block( InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock) { return block(multicastAddress, networkInterface, sourceToBlock, newPromise()); }
@Override public DatagramChannelConfig setTimeToLive(int ttl) { setOption0(IP_MULTICAST_TTL, ttl); return this; }
/** * Create a new instance using the given {@link SelectorProvider} and {@link InternetProtocolFamily}. * If {@link InternetProtocolFamily} is {@code null} it will depend on the Operation Systems default * which will be chosen. */ public NioDatagramChannel(SelectorProvider provider, InternetProtocolFamily ipFamily) { this(newSocket(provider, ipFamily)); }
/** * Create a new instance using the given {@link SelectorProvider}. */ public NioServerSocketChannel(SelectorProvider provider) { this(newSocket(provider)); }
@Override public DatagramChannelConfig setLoopbackModeDisabled(boolean loopbackModeDisabled) { setOption0(IP_MULTICAST_LOOP, loopbackModeDisabled); return this; }
/** * Create a new instance which will use the Operation Systems default {@link InternetProtocolFamily}. */ public NioDatagramChannel() { this(newSocket(DEFAULT_SELECTOR_PROVIDER)); }