套接字的连接和读取超时有什么区别? [英] What is the difference between connection and read timeout for sockets?

查看:848
本文介绍了套接字的连接和读取超时有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

3个问题:


  1. 连接 / strong>超时设置为无穷大是什么意思?

  1. What is the difference between connection and read timeout for sockets?

在什么情况下它可以保持在一个不定式循环中?

What does connection timeout set to "infinity" mean? In what situation can it remain in an infinitive loop? and what can trigger that the infinity-loop dies?

读取超时设置为无穷大是什么意思?在什么情况下它可以保持在一个不定式循环中?什么可以触发无限循环?

What does read timeout set to "infinity" mean? In what situation can it remain in an infinitive loop? and what can trigger that the infinity-loop dies?


推荐答案


1)sockets的连接和读取超时有什么区别?

1) What is the difference between connection and read timeout for sockets?

连接超时是超时初始连接;即完成TCP连接握手。读取超时是等待读取数据的超时。具体来说,如果服务器在最后一个字节后发送字节秒失败,则会产生读超时错误。

The connection timeout is the timeout in making the initial connection; i.e. completing the TCP connection handshake. The read timeout is the timeout on waiting to read data. Specifically, if the server fails to send a byte <timeout> seconds after the last byte, a read timeout error will be raised.


2)连接超时设置为无穷大是什么意思?在什么情况下它可以保持在一个不定式循环中?什么可以触发无限循环死亡?

2) What does connection timeout set to "infinity" mean? In what situation can it remain in an infinitive loop? and what can trigger that the infinity-loop dies?

这意味着连接尝试可能会永远阻塞。没有无限循环,但是尝试连接可以被另一个关闭套接字的线程解除阻塞。 (A Thread.interrupt() call也可以做这个窍门...不确定。)

It means that the connection attempt can potentially block for ever. There is no infinite loop, but the attempt to connect can be unblocked by another thread closing the socket. (A Thread.interrupt() call may also do the trick ... not sure.)


3)读取超时设置为无穷大是什么意思?在什么情况下它可以保持在一个不定式循环中?什么可以触发无限循环?

3) What does read timeout set to "infinity" mean? In what situation can it remain in an infinitive loop? and what can trigger that the infinity-loop dies?

这意味着调用在套接字流可能阻塞永远。再次没有无限循环,但可以通过 Thread.interrupt()调用解除阻塞,关闭套接字,以及(当然)另一端发送数据或关闭连接。

It means that a call to read on the socket stream may block for ever. Once again there is no infinite loop, but the read can be unblocked by a Thread.interrupt() call, closing the socket, and (of course) the other end sending data or closing the connection.

这篇关于套接字的连接和读取超时有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆