HTTP 持久连接与 TCP 套接字连接

发布于 2024-08-06 01:41:28 字数 480 浏览 3 评论 0原文

来自维基百科上的这篇文章:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幻梦 2024-08-13 01:41:28
  • 这是否意味着使用这种机制我实际上可以模拟
    TCP 套接字连接?

事实并非如此,套接字具有更多的功能和灵活性。

  • 使用它我可以让服务器将数据“推送”到客户端吗?

不是直接的,它仍然是一个请求/响应协议;持久连接只是意味着客户端可以使用相同的底层套接字发送多个请求并接收各自的响应。

  • 都是 HTTP 连接吗,甚至是我用来连接 Stack 的连接
    溢出“HTTP 持久”?

除非您的浏览器(或特殊服务器)另有说明,否则是的。

  • 服务器推送的COMET技术是否使用了HTTP的这种机制
    将数据推送到的持久连接
    客户?

有点(至少对于流媒体来说),但上面有很多生奶油。还有其他 Comet 实现方法,例如隐藏的 iframe 和 AJAX 长轮询,它们可能不需要持久连接(这给一些防火墙提供了支持;-)。

  • Does this mean that using this mechanism I can actually simulate a
    TCP socket connection?

Not really, sockets have MANY more features and flexibility.

  • Using this can I make a Server "push" data to a client?

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.

  • Are all HTTP connections, even the one I am using to connect to Stack
    Overflow "HTTP persistent"?

Unless your browser (or a peculiar server) says otherwise, yes.

  • Does the COMET technology of server push use this mechanism of HTTP
    persistent connection to push data to
    clients?

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;-).

自由范儿 2024-08-13 01:41:28

实际上,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文