use of io.netty.channel.FixedRecvByteBufAllocator in project vert.x by eclipse.
the class NetClientImpl method applyConnectionOptions.
private void applyConnectionOptions(Bootstrap bootstrap) {
if (options.getLocalAddress() != null) {
bootstrap.localAddress(options.getLocalAddress(), 0);
}
bootstrap.option(ChannelOption.TCP_NODELAY, options.isTcpNoDelay());
if (options.getSendBufferSize() != -1) {
bootstrap.option(ChannelOption.SO_SNDBUF, options.getSendBufferSize());
}
if (options.getReceiveBufferSize() != -1) {
bootstrap.option(ChannelOption.SO_RCVBUF, options.getReceiveBufferSize());
bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(options.getReceiveBufferSize()));
}
if (options.getSoLinger() != -1) {
bootstrap.option(ChannelOption.SO_LINGER, options.getSoLinger());
}
if (options.getTrafficClass() != -1) {
bootstrap.option(ChannelOption.IP_TOS, options.getTrafficClass());
}
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, options.getConnectTimeout());
bootstrap.option(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE);
bootstrap.option(ChannelOption.SO_KEEPALIVE, options.isTcpKeepAlive());
}
use of io.netty.channel.FixedRecvByteBufAllocator in project vert.x by eclipse.
the class DatagramSocketImpl method createChannel.
private static NioDatagramChannel createChannel(io.vertx.core.datagram.impl.InternetProtocolFamily family, DatagramSocketOptions options) {
NioDatagramChannel channel;
if (family == null) {
channel = new NioDatagramChannel();
} else {
switch(family) {
case IPv4:
channel = new NioDatagramChannel(InternetProtocolFamily.IPv4);
break;
case IPv6:
channel = new NioDatagramChannel(InternetProtocolFamily.IPv6);
break;
default:
channel = new NioDatagramChannel();
}
}
if (options.getSendBufferSize() != -1) {
channel.config().setSendBufferSize(options.getSendBufferSize());
}
if (options.getReceiveBufferSize() != -1) {
channel.config().setReceiveBufferSize(options.getReceiveBufferSize());
channel.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(options.getReceiveBufferSize()));
}
channel.config().setReuseAddress(options.isReuseAddress());
if (options.getTrafficClass() != -1) {
channel.config().setTrafficClass(options.getTrafficClass());
}
channel.config().setBroadcast(options.isBroadcast());
channel.config().setLoopbackModeDisabled(options.isLoopbackModeDisabled());
if (options.getMulticastTimeToLive() != -1) {
channel.config().setTimeToLive(options.getMulticastTimeToLive());
}
if (options.getMulticastNetworkInterface() != null) {
try {
channel.config().setNetworkInterface(NetworkInterface.getByName(options.getMulticastNetworkInterface()));
} catch (SocketException e) {
throw new IllegalArgumentException("Could not find network interface with name " + options.getMulticastNetworkInterface());
}
}
return channel;
}
Aggregations