C or C ++ library for encoding and decoding websocket frames

I have my own socket implementation supporting a connection to a regular tcp client. Now I would like to add websocket support to my server program. In this case, I will need to support handshaking protocols and messages, which are supported by major web browsers. I was able to handle the handshake, but was stuck in handling cropping and without cropping messages. Is there any existing C or C ++ library that handles the encoding and decoding of websocket message frames and supports the basic websocket protocols used by major web browsers?

Most of the current implementation I found (e.g. libwebsocket, websocketpp, etc.) implements its own server and client library, which means that I need to use their socket implementation. I do not want to do this because it will require me to change many things in my current program, and this is not an option for me. I just need a simple library that handles the encoding and decoding of the websocket framework (and / or also handles part of the handshake, but is optional).

+4
source share
3 answers

The author of the Websocketpp library is here.

The frame processing code and the handshake processing code are completely separate from the socket / network code. Look at the processor folder in the refactor policy branch. There is one for project 76 (hybi_legacy) and one for RFC6455 (hybi / hybi_header). Frame processors read from the STL stream, which you can fill in through your own network code or from another source.

Send me the prime minister on github if you have more specific questions.

+6
source

The websocketpp library websocketpp well designed, and the frame classes do not mix with the socket classes. There is a dependency on the BOOST and STL libraries. STL is not a problem, and the BOOST dependency is fairly easy to avoid. Just start with the websocket_frame.hpp file of the refactor policy branch.

+5
source

Frame c-parser (no handshake) you can find there

0
source

Source: https://habr.com/ru/post/1399522/


All Articles