是TCP保持确定断开链接的唯一机制? [英] Is TCP Keepalive the only mechanism to determine a broken link?

查看:211
本文介绍了是TCP保持确定断开链接的唯一机制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我遇到了一个问题,即betweeen TCP服务器和客户端的中间环节下跌。客户端具有连接到辅助服务器,如果主服务器宕机的要求。当主服务器是买下来(当然..by在终端上做^ C),还有就是通过获取和客户成功地检测到损坏的链接,并试图二级TCP关闭序列。但是,如果中间环节出现故障,客户端和服务器将不知道它。客户端可以检测到的唯一方式是,当它的TCP bufferes被充满了失败的发送操作。

I recently ran into a issue where intermediate link betweeen a TCP server and client was down. The client has the requirement of connecting to a secondary server if the primary server is down. When the primary server is bought down (Ex ..by doing ^C on the terminal), there is TCP shutdown sequence that gets through and client sucessfully detects the broken link and tries the secondary. However if the intermediate link goes down ,the client and server would be unaware of it. The only way the client can detect is when its TCP bufferes gets filled up with failed 'send' operations.

至于这个TCP保持机制的溶液已被使用。这工作satisfacatorily。

As a solution to this the 'TCP Keepalive' mechanism has been used. This works satisfacatorily.

我的问题是TCP保持唯一的解决办法?

My question is 'TCP Keepalive' the only solution?

-Prabhu

推荐答案

存活的目的是要对付所谓的半开连接,当双方(通常是收到请求的服务器)的人不知道该连接是破碎。客户通常知道它,因为尝试发送请求到服务器将返回错误。

Keepalive was designed to deal with so-called half-opened connections, when one of the sides (typically the server that receives the requests) is unaware that connection was broken. Client usually knows about it because the attempt to send request to the server will return you error.

另一种选择是保持监听运行 - 当客户端检测到通讯科的问题,它只是试图再次连接到服务器。服务器获取传入连接,检查它是否从相同的IP地址,并且如果是这种情况,关闭打开的连接,并建立一个新的。

Another option is to keep listener running - when client detects comms problems it just tries to connect to the server again. Server gets the incoming connection, check whether it from the same IP address, and if it is the case, closes opened connection and establishes a new one.

但是,如果客户端不知道该连接下楼和服务器需要发送的东西,也没有办法服务器重新建立连接,但TCP存活。

But if client is unaware that connection went down and server needs to send something, there is no way for server to re-establish connection but TCP keepalive.

如果你不想使用保活,你可以使用应用程序级的keepalive,例如发送类似应用程序特定的回应消息。

If you don't want to use keepalive, you can use application-level keepalive, e.g. sending something like application-specific echo messages.

这篇关于是TCP保持确定断开链接的唯一机制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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