且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

"java.io.IOException:连接超时"与"java.io.IOException:连接超时"有什么区别?和"SocketTimeoutException:读取超时";

更新时间:2022-04-15 22:41:33

连接超时意味着您尝试连接到远程IP/端口对,但未成功:根本没有应答.在该阶段的另一个可能的错误是连接被拒绝,其中该对可用,但拒绝了您的连接尝试.这两个错误都出现在套接字的初始设置中.请注意,这些错误仅发生在TCP上,因为TCP连接需要建立会话.

A connection timeout means you attempted to connect to the remote IP/port pair and failed to do so: it did not answer at all. Another possible error at that stage would be connection refused, in which this pair is available but rejected your connection attempt. Both of these errors appear on the initial setup of a socket. Note that these errors only occur with TCP, since a TCP connection requires the establishment of a session.

当套接字读取超时时,表示您已连接,但无法及时读取数据.套接字上的超时是可配置的.您可能还会收到连接重置错误,这意味着您确实连接成功,但是另一端认为毕竟不值得:p

When you have a socket read timeout, it means you are connected, but failed to read data in time. Timeouts on sockets are configurable. You may also get a connection reset error, which means you did connect successfully, but the other end decided that after all you're not worth it :p