Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

Windows Build Linux Build macOS Build license release

Why?

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.

Creating a Server Socket


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;
}

Creating a Socket (TCP Client)


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;

License

These libraries is licensed under the GNU GPLv3 License. Please read the License file to know about the usage terms and conditions.

About

C++ Server Socket and Socket classes

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages