我读了nio2的api,并找到了改进的方法:
AsynchronousSocketChannel.setOption(StandardSocketOptions.SO_RCVBUF, [size]);
AsynchronousSocketChannel.setOption(StandardSocketOptions.SO_SNDBUF, [size]);
[size] = RTT (from ping) * bandwidth (from net-card)
这些都是特定情况下的原因:
AsynchronousSocketChannel.setOption(StandardSocketOptions.TCP_NODELAY, ...);
AsynchronousSocketChannel.setOption(StandardSocketOptions.SO_REUSEADDR, ...);
AsynchronousSocketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, ...);
点对点还有其他方法吗?