This library porivdes there lightweight, Qt-inspired C++ classes for handling netowrk communication using BSD sockets. The design focuses on simplicity, performance, and clean object-oriented structure, making it ideal for use in high-performance, low-level systems while maintaining a familiar Qt-style API.
- TcpServer A non-blocking TCP server class built on top of poll(). It listens for incoming connections and creates new instances of TcpClient upon each accepted connection. Designed for scalability and easy intergration in event-driven applications.
- TcpClient A wrapper around a TCP socket, providing methods to connect to a remote host, sned and receive data, and monitor disconnection or errors. Internally uses poll() to watch the socket file descriptor, Inspired by QTcpSocket, this class includes customizable callbacks to simulate signal sucha as connected(), disconnected(), and dataReceived().
- Udp A simple, flexible class for sending and receiving datagrams using UDP. Supports both unicast and broadcast modes. Like QUdpSocket, it provides asynchronous-style event handling without depending on an external event loop.
- Fully asynchronous, event-driven architecture (poll-based)
- Qt-style API with custom signal/slot-like mechanism (via std::function)
- Minimal dependencies (pure C++17 and POSIX)
- Design with CPU efficiency and thread-safety in mind
- Easy to integrate into non-Qt systems or embedded environments
project_rooot
├── CMakeLists.txt
├── examples
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── TcpClientExample.cpp
│ ├── TcpServerExample.cpp
│ └── UdpExample.cpp
├── include
│ └── WeaNet
│ ├── Internal
│ │ ├── common.h
│ │ ├── enumPackets.h
│ │ ├── error.h
│ │ ├── logdatatype.cpp
│ │ ├── logdatatype.h
│ │ ├── net_enums.h
│ │ ├── network.h
│ │ ├── parserfile.cpp
│ │ ├── parserfile.h
│ │ └── WsaInitializer.h
│ ├── Manager.cpp
│ ├── Manager.h
│ ├── Tcp.h
│ └── Udp.h
├── install.sh
├── README.md
├── src
│ ├── internal
│ │ ├── error.cpp
│ │ └── network.cpp
│ ├── Tcp.cpp
│ └── Udp.cpp
├── tree.txt
├── uninstall.sh
├── WeaNetConfig.cmake.in
└── WeaNetUninstall.cmake.in
- Installation - Dependencies - Library Installation
- Usage - TcpClient - TcpServer - Udp - [CMake Usage] (#cmake-usage)
- Platforms
1- Qt5 Core lib.
2- C++ 17 POSIX
1- chmod +x install.sh
2- ./install.sh
3- Or if you want to install on specific path do this: ./install.sh /your/path/WeaNet
1- Build the Project.
2- cd /to/build/path/
3- cmake --install .
1- Referer to example/TcpClientExample.cpp
1- Referer to example/TcpServerExample.cpp
1- Referer to example/UdpExample.cpp
- You must include these lines to you Project CMakeLists.txt:
find_package(WeaNet REQUIRED)
# or you can Do by custom Prefix if the package isn't install to "/usr/local/WeaNet" or "C:\Program Files (x86)\WeaNet"
find_package(WeaNet REQUIRED PATHS "/to/your/installed/path/")
target_link_libraries(yourProjectName PRIVATE WeaNet::WeaNet)
# ONLY REQUIRED on Windows
if (_WIN32)
target_compile_definitions(WeaNetExamples PRIVATE _WIN32_WINNT=0x0A00)
endif()
Warning
Remember to always implement this line of code at below to your project CMakeLists.txt (If you are using Windows).
target_compile_definitions(WeaNetExamples PRIVATE _WIN32_WINNT=0x0A00)
1- Linux 2- Windows