HTTP 持久连接与 TCP 套接字连接
来自维基百科上的这篇文章:
Keepalive 消息并非正式消息 HTTP 1.0 中支持。在 HTTP 1.1 中所有 连接被认为是持久的, 除非另有声明。
- 这是否意味着使用这个 我实际上可以模拟一个机制 TCP套接字连接?
- 用这个我可以做一个服务器 将数据“推送”给客户端?
- 是否都是 HTTP 连接,甚至 我用来连接到 Stack 的一个 溢出“HTTP 持久”?
- COMET 技术是否 服务器推送使用这种机制 HTTP长连接推送 向客户提供数据?
From this article on Wikipedia:
Keepalive messages were not officially
supported in HTTP 1.0. In HTTP 1.1 all
connections are considered persistent,
unless declared otherwise.
- Does this mean that using this
mechanism I can actually simulate a
TCP socket connection? - Using this can I make a Server
"push" data to a client? - Are all HTTP connections, even the
one I am using to connect to Stack
Overflow "HTTP persistent"? - Does the COMET technology of
server push use this mechanism of
HTTP persistent connection to push
data to clients?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实并非如此,套接字具有更多的功能和灵活性。
不是直接的,它仍然是一个请求/响应协议;持久连接只是意味着客户端可以使用相同的底层套接字发送多个请求并接收各自的响应。
除非您的浏览器(或特殊服务器)另有说明,否则是的。
有点(至少对于流媒体来说),但上面有很多生奶油。还有其他 Comet 实现方法,例如隐藏的 iframe 和 AJAX 长轮询,它们可能不需要持久连接(这给一些防火墙提供了支持;-)。
Not really, sockets have MANY more features and flexibility.
Not directly, it's still a request/response protocol; the persistent connection just means the client can use the same underlying socket to send multiple requests and receive the respective responses.
Unless your browser (or a peculiar server) says otherwise, yes.
Kinda (for streaming, at least), but with a lot of whipped cream on top. There are other Comet implementation approaches, such as hidden iframes and AJAX long polling, that may not require persistent connections (which give some firewalls &c the fits anyway;-).
实际上,HTTP 服务器可以将数据“推送”到已连接的 http 客户端,而无需客户端请求。请参阅 http://en.wikipedia.org/wiki/Push_technology 上的“HTTP 服务器推送”。然而,它似乎确实被普遍实施。
Actually, the HTTP server can "push" data to a connected http client without the client requesting it. See "HTTP server push" at http://en.wikipedia.org/wiki/Push_technology. However it does seem to be commonly implemented.