logoalt Hacker News

mort96yesterday at 10:25 AM1 replyview on HN

Well, it also has the advantage of providing pretty decent encryption for free through WSS.

But yeah, where that's unnecessary, it's probably just as easy to have a 4-byte length prefix, since TCP handles the checksum and retransmit and everything for you.


Replies

mgaunardyesterday at 10:29 AM

It's just a standard TLS layer, works with any TCP protocol, nothing WebSocket-specific in it.

You should ideally design your messages to fit within a single Ethernet packet, so 2 bytes is more than enough for the size. Though I have sadly seen an increasing amount of developers send arbitrarily large network messages and not care about proper design.

show 1 reply