int mco_lews_is_websocket_close_frame(const char *buf, mco_size_t buf_size);
buf
buf_size
buf.This function is used to detect client-initiated WebSocket shutdown requests.
The function checks whether the provided buffer contains a valid WebSocket close control frame as defined in RFC 6455.
It validates the following aspects of the frame:
- Frame must be final (
FIN = 1).- No reserved bits set (
RSV1–RSV3 = 0).- Opcode must be
0x8(close).- Payload length must be ≤ 125 bytes and not equal to 1 byte.
- Frame must be complete (buffer size sufficient for header, mask, and payload).
- If a close status code is present (payload ≥ 2 bytes), it must be a valid WebSocket close code (e.g., 1000, 1001, 1002, etc.).
1
0