the client is developed using HTML5 WebSocket (ws://), the server is developed using realbasic using TCPSocket class.

Client has established a connection with server (I correctly send key and accept-key) but when client send a message to server, the message arrives encrypted. So, how I can decrypt this message with RB to read it correctly?

I use encode to make Accept-Key, the connection between client and server is established correctly.The problems come when client and server must exchange messages. This messages are encrypted and I don't know how to read them with RB.

From websocket.org:

Quote:

Once established, WebSocket data frames can be sent back and forth between the client and the server in full-duplex mode. Both text and binary frames can be sent in either direction at the same time. The data is minimally framed with just two bytes. In the case of text frames, each frame starts with a 0x00 byte, ends with a 0xFF byte, and contains UTF-8 data in between. WebSocket text frames use a terminator, while binary frames use a length prefix.

I use encode to make Accept-Key, the connection between client and server is established correctly.The problems come when client and server must exchange messages. This messages are encrypted and I don't know how to read them with RB.

From websocket.org:

Quote:

Once established, WebSocket data frames can be sent back and forth between the client and the server in full-duplex mode. Both text and binary frames can be sent in either direction at the same time. The data is minimally framed with just two bytes. In the case of text frames, each frame starts with a 0x00 byte, ends with a 0xFF byte, and contains UTF-8 data in between. WebSocket text frames use a terminator, while binary frames use a length prefix.

This is my problem.

You're going to have to implement the WebSocket protocol yourself. A TCPSocket doesn't know anything about particular protocols. That's why there are subclasses of TCPSocket for protocols like HTTP and SMTP. There's no built-in subclass for the WebSocket protocol; you will have to develop one.

Use MidB instead of Mid. Encoding shouldn't be an issue, but you never know.Substr() is zero-based. MidB is one-based. Increment all your offsets.Substr($payload, is not the same as Left(). Use Payload.MidB(9).