HTTP 协议无连接,默认使用 TCP,这有什么意义?
HTTP protocol connectionless and use TCP by default, How does that make sense?
我了解到 HTTP 协议默认使用可靠的 TCP 连接
,其中一项 HTTP 功能是无连接的。
现在我很困惑它有什么意义?
它如何使用 TCP,同时它是无连接的,据我所知,TCP 是面向连接的
HTTP 和 TCP 是不同的东西。 TCP is a transport layer protocol, whereas HTTP是一个应用层协议。 HTTP 使用 TCP 进行数据传输。
IMO this 网站有很好的解释:
HTTP is connectionless: The HTTP client, i.e., a browser initiates an HTTP request and after a request is made, the client waits for the response. The server processes the request and sends a response back after which client disconnect the connection. So client and server knows about each other during current request and response only. Further requests are made on new connection like client and server are new to each other.
但是,维基百科将 HTTP 定义为无状态的:
HTTP is a stateless protocol. A stateless protocol does not require the HTTP server to retain information or status about each user for the duration of multiple requests. However, some web applications implement states or server side sessions using for instance HTTP cookies or hidden variables within web forms.
根据他们的解释,这些术语似乎可以互换使用。然而,这些并不是真的,因为使用中的 HTTP 版本允许您通过 cookie 等识别用户并创建 persistent 连接。
我了解到 HTTP 协议默认使用可靠的 TCP 连接 ,其中一项 HTTP 功能是无连接的。 现在我很困惑它有什么意义? 它如何使用 TCP,同时它是无连接的,据我所知,TCP 是面向连接的
HTTP 和 TCP 是不同的东西。 TCP is a transport layer protocol, whereas HTTP是一个应用层协议。 HTTP 使用 TCP 进行数据传输。
IMO this 网站有很好的解释:
HTTP is connectionless: The HTTP client, i.e., a browser initiates an HTTP request and after a request is made, the client waits for the response. The server processes the request and sends a response back after which client disconnect the connection. So client and server knows about each other during current request and response only. Further requests are made on new connection like client and server are new to each other.
但是,维基百科将 HTTP 定义为无状态的:
HTTP is a stateless protocol. A stateless protocol does not require the HTTP server to retain information or status about each user for the duration of multiple requests. However, some web applications implement states or server side sessions using for instance HTTP cookies or hidden variables within web forms.
根据他们的解释,这些术语似乎可以互换使用。然而,这些并不是真的,因为使用中的 HTTP 版本允许您通过 cookie 等识别用户并创建 persistent 连接。