ASR4
ASR4

Reputation: 663

Long Polling vs HTTP Persistent Connection vs Web Sockets

Reading about the various http/tcp protocols and server-client connections these last few days has confused me a bit. I have read a lot of stackoverflow questions and articles that talk about Short-Polling vs Long Polling, Web Sockets vs simple Http Connections etc and I am still not satisfied.

This question is amazing: What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet? . But it does not answer how Http Persistent connection is different or similar to Web Sockets and Long Polling.

Here is my understanding:

Long Polling - Client makes a request the server keeps the connection open till it is ready to send the response back. One way to keep these connections open is by sending heartbeats to client periodically. This connection is also called long-lived connection.

Web-Sockets - There is an initial handshake between the client and server after which its a two-way street where the client and server talk to each other (sometimes also simultaneously). (They are also categorized as long-lived connection?)

HTTP Persistent Connection - Instead of a TCP handshake on every client request to the server, in a persistent connection a client (with the Connection: Keep-Alive header) opens a connection where many requests and responses take place one after the other in a particular connection. There can course be more persitent connections between the client and server where simultaneous request-response take place. (Are they also categorized as a long-lived connection?)

Is my understanding correct? Are all three categorized as long-live connections?

Upvotes: 5

Views: 1408

Answers (0)

Related Questions