HTTP Keep Alive和TCP保持活跃 [英] HTTP Keep Alive and TCP keep alive

查看:189
本文介绍了HTTP Keep Alive和TCP保持活跃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何实施HTTP Keep Alive?它内部是否使用TCP Keep Alive?如果没有,服务器如何检测客户端是死还是活?

How is HTTP Keep Alive implemented? Does it internally use TCP Keep Alive? If not, how does the server detect if the client is dead or alive?

推荐答案

HTTP Keep-Alive是HTTP协议的一项功能。实现Keep-Alive功能的Web服务器必须定期检查连接/套接字(对于传入的HTTP请求),因为它发送了最后一个HTTP响应(如果有相应的HTTP请求)。如果在配置的保持活动时间(秒)之前未收到HTTP请求,则Web服务器将关闭连接。在Web服务器完成关闭后,无法再进行HTTP请求。另一方面,TCP Keep-Alive由TCP层中的OS管理。 HTTP Keep-Alive和TCP Keep-Alive完全不相关。

HTTP Keep-Alive is a feature of HTTP protocol. The web-server, implementing Keep-Alive Feature, has to check the connection/socket periodically (for incoming HTTP request) for the time span since it sent the last HTTP response (in case there was corresponding HTTP Request). If no HTTP request is received by the time of the configured keep-alive time (seconds) the web server closes the connection. No further HTTP request will be possible after the 'close' done by Web Server. On the other hand, TCP Keep-Alive is managed by OS in the TCP layer. HTTP Keep-Alive and TCP Keep-Alive is totally unrelated things.

这篇关于HTTP Keep Alive和TCP保持活跃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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