简体   繁体   中英

How exactly does the websocket fragmention work?

I am working with a websocket server in php and I am encountering a problem. When the websocket fragment is too long, it will be splited into several fragments. However, I cannot find a websocket fragment decoder in php which can handle the fragmention for long data. So I decide to realize the decoder by myself. I read the RFC for websocket protocol, but I still don't understand how exactly does the fragmention work.

Here are the questions:

  1. When applying fragmention, every fragments has the independent FIN(for example, the last fragment's FIN is set while other fragments' FIN is zero) and opcode. But does every fragments has independent mask bit and masking key?

  2. Does the beginning fragment's payload length bits stand for the original data or just stand for the payload in the begining fragment and each fragment in fragmention has a payload length bits for itself?

Hope ur answering! I am quite confused.

  1. Every fragment should have independent mask bit and masking key.
  2. Payload length should represent a payload length of each fragment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM