HTTP 持久连接与 TCP 套接字连接 [英] HTTP persistent connection vs TCP socket connection

查看:30
本文介绍了HTTP 持久连接与 TCP 套接字连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

From this article on Wikipedia:

Keepalive 消息不是正式的HTTP 1.0 支持.在 HTTP 1.1 中所有连接被认为是持久的,除非另有声明.

Keepalive messages were not officially supported in HTTP 1.0. In HTTP 1.1 all connections are considered persistent, unless declared otherwise.

  • 这是否意味着使用这个我实际上可以模拟一个机制TCP套接字连接?
  • 用这个我可以做一个服务器将数据推送"到客户端?
  • 都是 HTTP 连接,即使是我用来连接到 Stack 的一个溢出HTTP 持久化"?
  • COMET 技术服务器推送使用这种机制要推送的 HTTP 持久连接向客户提供数据?
    • 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?
    • 推荐答案

      • 这是否意味着使用这种机制我实际上可以模拟一个TCP 套接字连接?

      并非如此,套接字具有许多更多的功能和灵活性.

      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.

      • 都是 HTTP 连接,甚至是我用来连接 Stack 的连接溢出HTTP 持久化"?

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

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

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

      有点(至少用于流媒体),但上面有很多生奶油.还有其他 Comet 实现方法,例如隐藏的 iframe 和 AJAX 长轮询,它们可能不需要持久连接(无论如何,这些方法都为一些防火墙提供了合适的选择;-).

      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 持久连接与 TCP 套接字连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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