Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

dak98/SocketIO

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

100 Commits
100 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SocketIO - a client-server library for C++

Traits

The main selling point of SocketIO is the freedom it gives to the user. It achieves this while also having unified and simple API.

It does not assume any messaging conventions - sending and receiving a message is done via objects of the std::string class. it makes the whole process simple to understand but expressive enough for most uses.

Support for both IPv4 and IPv6 is provided.

Dependencies

  • A POSIX-compliant operating system
  • A compiler supporting C++17
  • Google Test for running the tests

Obtain and install

git clone https://github.com/dak98/SocketIO.git
cd SocketIO
make
make install

Uninstall

make uninstall
make clean

Usage

Intialization

Creating a new server:

#include <socket_io/server.hpp>
using namespace socket_io;

server handle{"8000", ip_protocol::IPv4};

Creating a new client:

#include <socket_io/client.hpp>
using namespace socket_io;

client handle{"127.0.0.1", "8000"};

The connection with the server is established and managed automatically by the library. A mismatch in the protocols produces a runtime exception.

The server assigns an ID number (starting from 100 by default) to the new client and sends it back. It is necessary for communication.

Communication

Receiving a message (blocking):

std::string message = handle.receive();

The API here is the same for both the server and the client.

Sending a message from the server to the client:

handle.send(100, "Hello from the server");

The ID numbers of all the clients are stored in the registry.

Sending a message from the client to the server:

handle.send("Hello from the client");

It is up to the user of the library to implement the messaging between clients alongside their custom communcation protocol.

Example

The TalkNet project uses SocketIO with Qt to create a messaging application.

Testing

Building the tests:

make test

Running the tests:

./bin/tester

About

A client-server library for C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.