FBNetwork is a C++ network library that provides simple TCP client and server implementations with event queue integration. It is ideal as a foundation for your own network-based applications or to extend existing projects with network functionality.
- Simple TCP client and server classes
- Event-driven communication via EventQueue
- Modular architecture
- Extendable with optional MySQL integration
FBNetwork/
βββ include/
β βββ client.h # TCP Client Class
β βββ server.h # TCP Server Class
β βββ eventQueue.h # Event Management
β βββ extendedSystem.h # Platform-dependent extensions
β βββ mySQL.h # (Optional) MySQL Database Integration
βββ src/
β βββ client.cpp
β βββ server.cpp
β βββ eventQueue.cpp
β βββ extendedSystem.cpp
β βββ mySQL.cppgit clone https://github.com/Felix-Brodmann/FBNetwork.git
cd FBNetwork
mkdir build && cd build
cmake ..
makeNote: For MySQL functionality, libmysqlclient is required.
#include "server.hpp"
int main() {
try
{
FBNetwork::Server server(Domain::IPV4_DOMAIN, 12345, 20); // IPv4, Port 12345 and max 20 connections
server.startServer(); // Start the server
server.startListening(); // Start listening for incoming connections
int clientID = server.acceptClient(); // Accept a client connection in a blocking manner
std::cout << "Client connected with ID: " << clientID << " and IP: " << server.getClientIpAddress(clientID) << std::endl;
server.readTillXData(clientID, "\r\n"); // Read data until a specific delimiter
std::cout << "Received data from client: " << server.getData(clientID) << std::endl;
server.sendData(clientID, "Hello from server!"); // Send data to the client
server.closeClient(clientID); // Close the client connection
server.stopServer(); // Stop the server
}
catch (const std::exception& e)
{
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}
return 0;
}Pull requests and suggestions for improvement are always welcome!
FBNetwork Β© 2025 by Felix Brodmann is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International