[英]Are bytes on a TCP socket connection lost if the connection is severed before the bytes are read?
If I have a Selector
that's accepting sockets
and pushing them to a queue for other threads to handle, and no threads takes a socket for, say two minutes, and the client pushes data but then times out and disconnects. 如果我有一个Selector
的是公司的意见sockets
,并将其推到一个队列为其他线程来处理,并没有线程需要一个插座,说两分钟,客户端将数据推但随后超时并断开连接。 When a thread
then takes one of those now closed sockets
and tries to read from it, will it get the data that has already been sent by the client, or will there be nothing there to read? 当thread
然后使用那些现在关闭的sockets
并尝试从中读取时,它将获取客户端已发送的数据,还是没有什么要读取?
It depends on what 'severed' means. 这取决于“切断”的含义。
SocketException: socket closed
from the various read()
methods. 如果您自己关闭了套接字,则将获得SocketException: socket closed
各种read()
方法关闭的套接字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.