Giter VIP home page Giter VIP logo

socketio's Introduction

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

socketio's People

Contributors

dak98 avatar

Stargazers

 avatar  avatar  avatar

Forkers

hellocvitamin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.