How to parse and validate a WebSocket frame in Java?

前端 未结 4 1950
慢半拍i
慢半拍i 2021-01-14 19:10

I wrote a WebSocket frame decoder in Java:

private byte[] decodeFrame(byte[] _rawIn) {
        int maskIndex = 2;
        byte[] maskBytes = new byte[4];

           


        
4条回答
  •  北恋
    北恋 (楼主)
    2021-01-14 19:38

    The websocket protocol does not include checksums of any kind, if that's what you're looking for. If there's an error in a data frame the only way you'll know is because the data comes out wrong or because subsequent frames come out "funny" (unexpected opcode, longer or shorter than expected, etc).

提交回复
热议问题