A lightweight WebSocket server implementation in C++, built from scratch following RFC 6455. No external WebSocket dependencies - just raw socket programming with OpenSSL.
- RFC 6455 compliant WebSocket protocol implementation
- WebSocket handshake with SHA-1 and Base64
- Frame parsing with masking/unmasking
- Multi-threaded client handling
- Available as both static and dynamic library
- Browser-based test client included
- C++17
- CMake 3.10+
- OpenSSL
mkdir build && cd build
cmake ..
makefind_package(OpenSSL REQUIRED)
find_library(WEBSOCKET_LIB websocket)
add_executable(your_app main.cpp)
target_link_libraries(your_app
PRIVATE
${WEBSOCKET_LIB}
OpenSSL::SSL
OpenSSL::Crypto
pthread
)#include <websocket.hpp>
int main() {
WebSocket server(8080);
server.onMessage([](const std::string& msg) {
std::cout << "Received: " << msg << std::endl;
});
server.start();
return 0;
}websocket.hpp - WebSocket class definition
websocket.cpp - Protocol implementation (handshake, framing, masking)
main.cpp - Example server
index.html - Browser test client
CMakeLists.txt - Build configuration
MIT