'How to send message to client in Socket.Stream?

There is an application in C # to which I need to attach a web interface with a minimum response time (several timers are displayed), so I want to connect via socket mozilla has a great example just for me. It already shows the connection, handshake and reading a message from the client. Bonus, the JS side is shown. It just doesn't show how to compose a response to the client. The following page shows what bytes the message is from, but I still don't I can make it right. Whenever you try to send something to the client, the connection is immediately terminated, even if you send the same byte array that came. Please help me to make the function of sending a message, I couldn't myself ((



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source