7월, 2022의 게시물 표시

C++ - Websocket Programming #2

이미지
 This time, we will implement a websocket client in a C++ program instead of a browser. There are various libraries that can implement WebSocket in C++ programs. In this article, I will introduce an example that can implement WebSocket with only one cpp file and one header file. easywsclient The websocket library I would recommend and use is https://github.com/dhbaird/easywsclient . Download easywsclient.cpp and easywsclient.hpp files from the above site and save them in your project directory.  And this site provides websocket example files example-client-cpp11.cpp and example-client.cpp files. And this site provides websocket example files example-client-cpp11.cpp and example-client.cpp files. I will modify these files slightly and connect to Node-RED websocket. Build working C++ example on node-red First, download the source code from github. [ spypiggy@localhost study ] $ git clone https://github.com/dhbaird/easywsclient.git Cloning into 'easywsclient' ... rem...

C++ - Websocket Programming #1

이미지
 WebSocket allows you to exchange data while maintaining a connection between the server and the browser. At this point, the data is delivered in the form of a 'packet', and the transfer takes place in both directions without connection interruption and additional HTTP requests. Because of this feature, WebSockets are ideal for services that require continuous data exchange, such as online games and stock trading systems. For this reason, Websocket is mainly implemented using Javascript, a language for browsers. However, sometimes you need to use WebSockets in C++. For example, if the server system is built assuming that the browser is the client, and a program developed in C++ needs to connect to this server and receive service, then you need to implement Websocket in your C++ program. Simple Websocket Server (Node-RED) For testing purposes, we will implement a simple websocket server. My favorite method is to use Node-RED. Node-RED has already created Websocket nodes. Install...