I want to be able to send data over a websocket in my C++ code? Is there some library or standard way that this is done? Thanks for the help, I appreciate it, and please let me know if I should provide more information.
-
What is your OS and compiler? – Steve Townsend Jan 06 '11 at 18:59
-
Possible duplicate of: http://stackoverflow.com/questions/4147715/i-am-looking-for-a-simple-socket-interface-for-c-using-ms-visual-c-express/4147766 – yasouser Jan 06 '11 at 19:00
-
@anand: I don't think websockets are quite the same as sockets. – Null Set Jan 06 '11 at 19:08
-
1It is however a possible duplicate of this: http://stackoverflow.com/questions/3916217/standalone-c-websocket-server-library – Null Set Jan 06 '11 at 19:10
7 Answers
Please have a look at https://github.com/zaphoyd/websocketpp, which is based on Boost ASIO.
You can find a comparison of websocket implementations at http://en.wikipedia.org/wiki/Comparison_of_WebSocket_implementations.

- 246
- 1
- 4
- 11
Checkout Boost Asio library.

- 5,113
- 2
- 27
- 41
-
4Does Boost::Asio support Websockets as of now? The last time I checked they did not. Note, that Websockets are not identical to normal sockets. – MKroehnert Feb 17 '11 at 15:16
Beast is a C++ library using Boost Asio, demonstrated at CppCon 2016 and used in rippled, an open source server application that implements a decentralized cryptocurrency system.
Also see this related question and this one.
cURL is probably going to be a little bit more highlevel and easier to use than boost, esp if this is HTTP you are looking at.

- 33,299
- 2
- 62
- 101
-
are you sure will it work for websocket ? Note http and websocket are related but different technologies. – Gray Programmerz Oct 05 '22 at 11:57
Check out the link to libwebsocket in the answer of warmcat to my question (Standalone C++ websocket server library) which was posted earlier.
Note that libwebsocket can be used for client and server side websockets.

- 1
- 1

- 3,637
- 2
- 34
- 43
For a pure C++ approach to WebSockets using Boost.Asio check out: https://github.com/eidheim/Simple-WebSocket-Server

- 121
- 2
- 4
Lots of different ones, but you'd probably find the Boost libraries helpful.

- 110,348
- 25
- 193
- 263