I created these libraries because I didn't find a library for simple Sockets class (as Java) that was easy, clean and full C++ style. In addition, I'm a student looking for creative ideas so it seemed like an opportunity to train.
There're already libraries in C++ that allow you to use sockets in a structured way, but none of these have a simple syntax similar to the C++ Standard Library.
The initial structure starts from the davidsteinsland project, from which I fork.
So make good use of it and remember that's completely open source under the GPLv3 License.
net::serversocket* server = new net::serversocket(8002);
const int err = server->listen();
if (err != 0) {
std::cerr << strerror(err) << '\n';
exit(err);
}
while (true) {
net::socket* client = server->accept();
if (!client->valid()) {
delete client;
continue;
}
std::string message;
client->read(&message);
std::cout << "Message: " << message << std::endl;
}
net::socket* client = new net::socket();
if (client->connect("127.0.0.1", 8002) == CONNECT_ERROR)
std::cerr << "Problem with connection!\n";
client->sendln("Hello guys!");
std::cout << client->read() << std::endl;
These libraries is licensed under the GNU GPLv3 License. Please read the License file to know about the usage terms and conditions.
