void WebSocket::SendRequest() { ........................................ for(int i = 0; i < 20; i++) h.Cat(Random()); ........................................ }
void WebSocket::SendRequest() { ........................................ for(int i = 0; i < 16; i++) h.Cat(Random()); ........................................ }
The value of this header field MUST be a nonce consisting of a randomly selected 16-byte value that has been base64-encoded.
NOTE: As an example, if the randomly selected value was the sequence of bytes 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10, the value of the header field would be "AQIDBAUGBwgJCgsMDQ4PEC=="
void WebSocket::Close(const String& msg, bool wait_reply) { ........................................ SendRaw(CLOSE|FIN, msg); ........................................ } void WebSocket::FrameData() { ........................................ SendRaw(PONG|FIN, data); ........................................ }
void WebSocket::Close(const String& msg, bool wait_reply) { ........................................ SendRaw(CLOSE|FIN, msg, MASK); ........................................ } void WebSocket::FrameData() { ........................................ SendRaw(PONG|FIN, data, MASK); ........................................ }
A client MUST mask all frames that it sends to the server (Note that masking is done whether or not the WebSocket Protocol is running over TLS)
The server MUST close the connection upon receiving a frame that is not masked. In this case, a server MAY send a Close frame with a status code of 1002 (protocol error)
A server MUST NOT mask any frames that it sends to the client. A client MUST close a connection if it detects a masked frame.