Java 如何理解http put的SocketTimeout?

Java 如何理解http put的SocketTimeout?,java,sockets,http,timeout,Java,Sockets,Http,Timeout,从java.net.SocketsetSoTimeout的javadoc中可以看出: 对于http put操作,客户机可能上载一个巨大的文件,客户机总是在写入该文件,而从不从服务器读取数据 在这种情况下,如果我为http客户端设置SocketTimeout,它在上传过程中会抛出TimeoutException吗?不会。但是,在读取响应代码时,它可能会引发超时异常。如果对等方在上载过程中关闭连接,它将抛出IOException“由对等方重置连接” Enable/disable SO_TIMEO

从java.net.SocketsetSoTimeout的javadoc中可以看出:

对于http put操作,客户机可能上载一个巨大的文件,客户机总是在写入该文件,而从不从服务器读取数据


在这种情况下,如果我为http客户端设置SocketTimeout,它在上传过程中会抛出TimeoutException吗?

不会。但是,在读取响应代码时,它可能会引发超时异常。如果对等方在上载过程中关闭连接,它将抛出IOException“由对等方重置连接”

  Enable/disable SO_TIMEOUT with the specified timeout, in
  milliseconds.  With this option set to a non-zero timeout,
  a read() call on the InputStream associated with this Socket
  will block for only this amount of time.  If the timeout expires,
  a <B>java.net.SocketTimeoutException</B> is raised, though the
  Socket is still valid.