Startec
Startec

Reputation: 13246

If websockets use a TCP connection is communication over them as slow as TCP?

From what I gather, Websockets use a TCP (or what amounts to TCP) connection for data transfer. If this is the case, are messages traveling at TCP speeds?

Further complicating my understanding is Socket.IO which, in node, sometimes can initiate a Websocket connection using HTTP (by using express for instance). When this happens is the websocket information being sent at HTTP speeds or something else?

Lastly, in node, I have an application that makes a UDP connection to the server, and then send the udp over the socket.io connection. Is this UDP data being sent at the tcp speeds in this scenario?

Thanks

Upvotes: 0

Views: 1721

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123631

WebSockets are a protocol upgrade within an HTTP connection (e.g. TCP) with its own framing - which means that it is a layer on top of TCP and due to its own framing it has even more overhead than TCP alone.

Apart from that, TCP packets by themselves are not slower than UDP packets and data transfer with a simple TCP connection can be faster than with a simple UDP connection, because flow control and reliable transfer is already integrated and you don't have to reinvent everything again (and often worse).

Upvotes: 2

Related Questions