TCP 套接字连接是否具有“保持活动状态"?

编程入门 行业动态 更新时间:2024-10-10 21:24:49
本文介绍了TCP 套接字连接是否具有“保持活动状态"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我听说过 HTTP keep-alive,但现在我想打开一个与远程服务器的套接字连接.现在这个套接字连接是否会永远保持打开状态,或者是否存在与 HTTP keep-alive 类似的超时限制?

I have heard of HTTP keep-alive but for now I want to open a socket connection with a remote server. Now will this socket connection remain open forever or is there a timeout limit associated with it similar to HTTP keep-alive?

推荐答案

TCP 套接字在关闭之前保持打开状态.

TCP sockets remain open till they are closed.

也就是说,在不实际发送数据的情况下很难检测到断开的连接(断开的,例如路由器死机等,而不是关闭),因此大多数应用程序每隔一段时间就会进行某种乒乓反应以确保连接实际上仍然有效.

That said, it's very difficult to detect a broken connection (broken, as in a router died, etc, as opposed to closed) without actually sending data, so most applications do some sort of ping/pong reaction every so often just to make sure the connection is still actually alive.

更多推荐

TCP 套接字连接是否具有“保持活动状态"?

本文发布于:2023-11-25 06:35:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628692.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   TCP   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!