java中socke连接t默认超时时间
socket超时时间设置为一分钟,貌似20秒就断了,是不是做大时间为20秒,这个貌似跟操作系统有关吗??不同系统超时时间不同吗?
顺带问下,jdk中PlainSocketImpl类中的private native void socketConnect(InetAddress address, int port, int timeout) 方法源码给个详细点介绍???
------解决方案--------------------默认无限。
public void connect(SocketAddress endpoint,
int timeout)
throws
IOException
Connects this socket to the server with a specified timeout value.
A timeout of zero is interpreted as an infinite timeout.
The connection will then block until established or an error occurs.
Parameters:
endpoint - the SocketAddress
timeout - the timeout value to be used in milliseconds.