Reputation: 23
This is more a question of interest than necessity;
I am writing a small implication of websocket communication for an embedded system, and found the theoretical size limit of a single frame to be specified at 2^64 bytes.
I have decided to only implement support for the shorter specification of 2^16, but I started wondering, why did they decide to make the max frame size so large, when the specification states that you must use a TCP connection, and TCP has a maximum payload size of 65535 bytes?
Upvotes: 1
Views: 3366
Reputation: 19221
The WebSocket protocol allows each message to be fragmented across multiple TCP/IP packets. This allows a 4Gb message to be split into thousands of TCP/IP packets during transmission.
Note that WebSockets implement a message based protocol over the TCP/IP stream... WebSockets is not a streaming protocol.
For this reason, the TCP/IP packet size limit is irrelevant. The only practical limits are the system's limits and security concerns - can the system handle 64 bit message sizes? is it limited to 32 bits? should users be allowed to send huge messages? what limits should a system impose on the incoming messages in order to prevent users from attacking the system? ... etc'.
Upvotes: 2