Question

I'm just not very familiar with the network technology.

I was wondering when the SSE and WebSocket are both communicating over HTTP, is there also the famous TCP 3-way handshake before the HTTP connection?

If yes, the WebSocket would have two 3-way handshakes? One over TCP and the second for the upgrade-method over HTTP?

Thanks in advance!

Was it helpful?

Solution

That is correct.

HTTP builds on top of TCP. This means that the HTTP packets are within TCP packets. And every HTTP connection needs to go through a TCP handshake first.

Server-Sent-Events is basically just a long-running HTTP request that sends out data from the server to the client when it wants to. It uses standard HTTP headers to provide additional information.

WebSockets is a completely new protocol that uses HTTP to initiate the connection. The connection gets upgraded to the new protocol. The main purpose of the WebSocket handshake is to make sure both parties are talking the same protocol and want to talk to each other at the level of that protocol.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top