Websocket: Send a close frame with status code when receiving invalid frames

According to the websocket specification peers may send a close frame when they detect a protocol violation (with status code 1002). The current implementation simply closes the connection. This update should add this functionality. The functionality is optional - but it might help other implementations with debugging when they receive such a frame.