netty的网络配置

ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);//这里我们需要关注ChannelOption类
//用于指定是否使用对象池,一般使用默认,即不用配置。详情见:ByteBufAllocator
ChannelOption ALLOCATOR = valueOf("ALLOCATOR");
//Channel接受Buffer的分配器,默认值为AdaptiveRecvByteBufAllocator.DEFAULT。可选值为FixedRecvByteBufAllocator,固定大小的接受缓冲区分配器。
ChannelOption RCVBUF_ALLOCATOR = valueOf("RCVBUF_ALLOCATOR");
//消息大小估算器
ChannelOption MESSAGE_SIZE_ESTIMATOR = valueOf("MESSAGE_SIZE_ESTIMATOR");
//netty的client链接server的超时时间。
ChannelOption CONNECT_TIMEOUT_MILLIS = valueOf("CONNECT_TIMEOUT_MILLIS");
//一次Loop读取的最大消息数
ChannelOption MAX_MESSAGES_PER_READ = valueOf("MAX_MESSAGES_PER_READ");
//一个Loop写操作执行的最大次数,默认值为16。也就是说,对于大数据量的写操作至多进行16次,如果16次仍没有全部写完数据,
//此时会提交一个新的写任务给EventLoop,任务将在下次调度继续执行。
//这样,其他的写请求才能被响应不会因为单个大数据量写请求而耽误。
ChannelOption WRITE_SPIN_COUNT = valueOf("WRITE_SPIN_COUNT");
ChannelOption WRITE_BUFFER_HIGH_WATER_MARK = valueOf("WRITE_BUFFER_HIGH_WATER_MARK");
ChannelOption WRITE_BUFFER_LOW_WATER_MARK = valueOf("WRITE_BUFFER_LOW_WATER_MARK");
//一个连接的远端关闭时本地端是否关闭,默认值为False。值为False时,连接自动关闭;为True时,触发ChannelInboundHandler的userEventTriggered()方法,事件为ChannelInputShutdownEvent。
ChannelOption ALLOW_HALF_CLOSURE = valueOf("ALLOW_HALF_CLOSURE");
ChannelOption AUTO_READ = valueOf("AUTO_READ");
ChannelOption AUTO_CLOSE = valueOf("AUTO_CLOSE");
ChannelOption SO_BROADCAST = valueOf("SO_BROADCAST");
ChannelOption SO_KEEPALIVE = valueOf("SO_KEEPALIVE");
ChannelOption SO_SNDBUF = valueOf("SO_SNDBUF");
ChannelOption SO_RCVBUF = valueOf("SO_RCVBUF");
ChannelOption SO_REUSEADDR = valueOf("SO_REUSEADDR");
ChannelOption SO_LINGER = valueOf("SO_LINGER");
ChannelOption SO_BACKLOG = valueOf("SO_BACKLOG");
ChannelOption SO_TIMEOUT = valueOf("SO_TIMEOUT");
ChannelOption IP_TOS = valueOf("IP_TOS");
ChannelOption IP_MULTICAST_ADDR = valueOf("IP_MULTICAST_ADDR");
ChannelOption IP_MULTICAST_IF = valueOf("IP_MULTICAST_IF");
ChannelOption IP_MULTICAST_TTL = valueOf("IP_MULTICAST_TTL");
ChannelOption IP_MULTICAST_LOOP_DISABLED = valueOf("IP_MULTICAST_LOOP_DISABLED");
ChannelOption TCP_NODELAY = valueOf("TCP_NODELAY");
@Deprecated
ChannelOption AIO_READ_TIMEOUT = valueOf("AIO_READ_TIMEOUT");
@Deprecated
ChannelOption AIO_WRITE_TIMEOUT = valueOf("AIO_WRITE_TIMEOUT");
@Deprecated
ChannelOption DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION = valueOf("DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION");
ChannelOption SINGLE_EVENTEXECUTOR_PER_GROUP = valueOf("SINGLE_EVENTEXECUTOR_PER_GROUP");

你可能感兴趣的:(netty的网络配置)