如何使用套接字操作通知无响应的 TCP 服务器?
How to notify about a non responsive TCP server using socket operations?
我对socket编程的理解主要来源于这个教程:
CS 50 Software Design and Implementation, Lecture 19, Socket Programming
给定一个 TCP client/server 模型,其中客户端和服务器 运行 在两个不同的系统中,并且在它们之间有一个代理,假设客户端能够通过代理,然后服务器突然变得无响应(比如说它被重置了)。代理和服务器之间的连接发生了什么,如何处理?
我的意思是,我可以使用什么技术来检测此类事件、关闭我的连接并return向客户端发送错误消息?
我能想到的一种方法是检查代理中的接收缓冲区,如果一段时间内没有数据,则告诉客户端服务器已关闭。但我认为超时是一种原始的方法。在套接字编程中是否有任何已知的标准方法或替代方法可用?
Given a TCP client/server model where the client and server are running in two different systems and a proxy is in between them, assume the client is able to send messages to the server through the proxy, then the server suddenly becomes non-responsive (say it got reset). What happens to the connection between the proxy and server
或者:
- 没有。
- 读取超时,或
- 一个'connection reset'错误
完全取决于代理在做什么。如果它正在接收,则 (2),或者 (3) 如果已经有待发送。如果它正在发送,(3),但不是在第一次发送时,因为有缓冲。最终发送将导致 (3).
and how to handle this?
关闭连接,并连接到客户端。如果是重置,您可能希望通过一种我不会在此处记录的技术将其传播给客户端,因为它被广泛滥用。如果是读取超时,您甚至可能想尝试通过简单地在五分钟或任何适当的时间内不执行任何操作,然后关闭或重置连接来将其传播给客户端。
I mean, what technique can I employ to detect such an event, close my connection, and return an error message to the client?
见上文。
One way I can think of is to check the receive buffer in the proxy, and if there is no data in it for some time, tell the client that the server is down. But I think that timeout is a primitive approach.
不是。
Are there any known standard methods or alternatives available in socket programming for this?
见上文。
我对socket编程的理解主要来源于这个教程:
CS 50 Software Design and Implementation, Lecture 19, Socket Programming
给定一个 TCP client/server 模型,其中客户端和服务器 运行 在两个不同的系统中,并且在它们之间有一个代理,假设客户端能够通过代理,然后服务器突然变得无响应(比如说它被重置了)。代理和服务器之间的连接发生了什么,如何处理?
我的意思是,我可以使用什么技术来检测此类事件、关闭我的连接并return向客户端发送错误消息?
我能想到的一种方法是检查代理中的接收缓冲区,如果一段时间内没有数据,则告诉客户端服务器已关闭。但我认为超时是一种原始的方法。在套接字编程中是否有任何已知的标准方法或替代方法可用?
Given a TCP client/server model where the client and server are running in two different systems and a proxy is in between them, assume the client is able to send messages to the server through the proxy, then the server suddenly becomes non-responsive (say it got reset). What happens to the connection between the proxy and server
或者:
- 没有。
- 读取超时,或
- 一个'connection reset'错误
完全取决于代理在做什么。如果它正在接收,则 (2),或者 (3) 如果已经有待发送。如果它正在发送,(3),但不是在第一次发送时,因为有缓冲。最终发送将导致 (3).
and how to handle this?
关闭连接,并连接到客户端。如果是重置,您可能希望通过一种我不会在此处记录的技术将其传播给客户端,因为它被广泛滥用。如果是读取超时,您甚至可能想尝试通过简单地在五分钟或任何适当的时间内不执行任何操作,然后关闭或重置连接来将其传播给客户端。
I mean, what technique can I employ to detect such an event, close my connection, and return an error message to the client?
见上文。
One way I can think of is to check the receive buffer in the proxy, and if there is no data in it for some time, tell the client that the server is down. But I think that timeout is a primitive approach.
不是。
Are there any known standard methods or alternatives available in socket programming for this?
见上文。