This project is a C++ command-line WebSocket client application that connects to public echo servers, sends and receives messages, and supports secure WebSocket (wss) connections. It is built using the GN (Generate Ninja) build system, includes unit tests, and supports both GCC and Clang compilers.
- Connects to public WebSocket echo servers
- Send and receive text messages
- Command-line interface for interaction
- Graceful handling of connection errors and disconnections
- SSL/TLS support for secure WebSocket connections
- GN build system with separate debug and release targets
- Unit tests for critical components
- Compatible with both GCC and Clang compilers
- C++17 compatible compiler (GCC or Clang)
- Python (for GN generation)
- Ninja build system
- OpenSSL (for wss support)
-
Clone and build GN:
git clone https://gn.googlesource.com/gn cd gn python build/gen.py ninja -C out
-
Add the GN binary to your system PATH
- Generate build files with GN
- Build using Ninja
Navigate to the output directory and run the compiled binary.
The program will prompt you to enter messages to send and display messages received from the echo server.
Unit tests are located in the test/
directory.
Tests cover:
- Successful connection and disconnection
- Message send and receive operations
- Error scenarios
This project supports secure WebSocket connections (wss) using OpenSSL. Make sure OpenSSL is installed and properly linked during compilation. You can use pkg-config
or manually configure GN args to link OpenSSL libraries.
- wss://echo.websocket.events/
- https://websocket.org/tools/websocket-echo-server
- https://piehost.com/websocket-tester
- Secure WebSocket (wss://) with OpenSSL
- Compatible with both GCC and Clang compilers
- Modular code with separation of concerns
- Unit test suite for core components
- WebSocket RFC 6455: https://tools.ietf.org/html/rfc6455
- GN Build System Documentation: https://gn.googlesource.com/gn/+/master/docs/
- CLI11 (Command-Line Interface Library): https://github.com/CLIUtils/CLI11
- WebSocket Echo Test Tool: https://www.websocket.org/echo.html