// set acceptor props
acceptor.setHandler(ioHandler);
// requested maximum length of the queue of incoming connections
acceptor.setBacklog(backlog);
// get the current session config that would be used during create
SocketSessionConfig sessionConf = acceptor.getSessionConfig();
// reuse the addresses
sessionConf.setReuseAddress(true);
sessionConf.setTcpNoDelay(tcpNoDelay);
sessionConf.setSendBufferSize(sendBufferSize);
//
sessionConf.setReceiveBufferSize(receiveBufferSize);
sessionConf.setMaxReadBufferSize(receiveBufferSize);
// sets the interval (seconds) between each throughput calculation, the default value is 3 seconds
sessionConf.setThroughputCalculationInterval(thoughputCalcInterval);
// set the reader idle time (seconds)
sessionConf.setReaderIdleTime(readerIdleTime);
sessionConf.setKeepAlive(keepAlive);
// to prevent setting of the traffic class we expect a value of -1
if (trafficClass == -1) {
log.info("Traffic class modification is disabled");
} else {
// set the traffic class - http://docs.oracle.com/javase/6/docs/api/java/net/Socket.html#setTrafficClass(int)
// IPTOS_LOWCOST (0x02)
// IPTOS_RELIABILITY (0x04)
// IPTOS_THROUGHPUT (0x08) *
// IPTOS_LOWDELAY (0x10) *
sessionConf.setTrafficClass(trafficClass);
}
// get info
log.info("Send buffer size: {} recv buffer size: {} so linger: {} traffic class: {}", new Object[] { sessionConf.getSendBufferSize(), sessionConf.getReceiveBufferSize(),
sessionConf.getSoLinger(), sessionConf.getTrafficClass() });
// set reuse address on the socket acceptor as well
acceptor.setReuseAddress(true);
try {
// loop through the addresses and bind
Set<InetSocketAddress> socketAddresses = new HashSet<InetSocketAddress>();