第一种方法
改注册表
改变这个变量:MaxUserPort可用端口数量由1024扩展为65535
改变这个变量:TcpTimedWaitDelay 把它缩短到30s
//先站个位置
public void startConnection( HttpDestination destination )
throws IOException
{
SocketChannel channel = null;
try
{
channel = SocketChannel.open();
Address address = destination.isProxied() ? destination.getProxy() : destination.getAddress();
channel.socket().setTcpNoDelay(true);
channel.socket().setReuseAddress(true);
channel.socket().setSoLinger(true, 0);
if (_httpClient.isConnectBlocking())
{
channel.socket().connect(address.toSocketAddress(), _httpClient.getConnectTimeout());
channel.configureBlocking(false);
_selectorManager.register( channel, destination );
}
else
{
channel.configureBlocking(false);
channel.connect(address.toSocketAddress());
_selectorManager.register(channel,destination);
ConnectTimeout connectTimeout = new ConnectTimeout(channel,destination);
_httpClient.schedule(connectTimeout,_httpClient.getConnectTimeout());
_connectingChannels.put(channel,connectTimeout);
}
}
http://www.blogjava.net/yongboy/archive/2015/02/25/423037.html
http://www.apihome.cn/api/java/Socket.html
http://www.blogjava.net/yongboy/archive/2015/02/25/423037.html
http://blog.youkuaiyun.com/zjl410091917/article/details/7990787
http://bbs.youkuaiyun.com/topics/390924834
http://blog.youkuaiyun.com/feiyinzilgd/article/details/5894300