Subevent

C++ Event Driven and Network Application Library (Header only)
Alternatives To Subevent
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Twisted5,0069,6955512 days ago90April 11, 20222,739otherPython
Event-driven networking engine written in Python.
Message Io86449 days ago44June 07, 202210apache-2.0Rust
Fast and easy-to-use event-driven network library.
Salt Sproxy10225 months ago29July 01, 202122apache-2.0Python
Salt plugin to automate the management and configuration of (network) devices at scale, without running (Proxy) Minions.
Collie601435 years ago80August 30, 20183D
An asynchronous event-driven network framework( port netty ) written in D.
Jabs45
7 months agomitJava
a blockchain network simulator aimed at researching consensus algorithms for performance and security
Netpoll423a month ago17October 30, 20212mitGo
Package netpoll implements a network poller based on epoll/kqueue.
Ev17
2 months agobsd-2-clauseC
Lightweight event-loop library based on multiplexing IO
Vaser16
5 years agoC#
Vaser is a powerful high performance event based network engine library for C# .Net. It’s possible to start multiple servers in one program and use the same network code for all servers. In the network communication are all strings are omitted, instead it is based on a unique binary identifier, which the CPU and memory relieves massively.
Subevent10
4 years agomitC++
C++ Event Driven and Network Application Library (Header only)
Cio8
2 days ago11otherC
An ANSI C Conformant I/O Library.
Alternatives To Subevent
Select To Compare


Alternative Project Comparisons
Readme

Subevent

C++ Event Driven and Network Application Library

Features

  • Event driven App/Thread.
  • Async TCP/UDP client and server.
  • Async HTTP/HTTPS client and server.
  • Async WebSocket client and server.
  • Multiple connections in single thread.
  • Header only.
  • Easy to use.

Requirements

  • C++11 or later
  • Linux, Windows, macOS
  • OpenSSL ( if use secure protocol (https, wss) )

Compile Options

  • -std=c++11 (or later option)
  • -pthread or -lpthread
  • -lssl and -lcrypt (for OpenSSL)

Example

  • Simple Application
#include <subevent/subevent.hpp>

SEV_USING_NS

//---------------------------------------------------------------------------//
// Main
//---------------------------------------------------------------------------//

SEV_IMPL_GLOBAL

int main(int, char**)
{
    NetApplication app;

    // your code here.

    return app.run();
}
  • Custom Application Class
#include <subevent/subevent.hpp>

SEV_USING_NS

//---------------------------------------------------------------------------//
// MyApp
//---------------------------------------------------------------------------//

class MyApp : public NetApplication
{
protected:
    bool onInit() override
    {
        NetApplication::onInit();

        // Your initialization code here.

        return true;
    }

    void onExit() override
    {
        // Your deinitialization code here.

        NetApplication::onExit();
    }
};

//---------------------------------------------------------------------------//
// Main
//---------------------------------------------------------------------------//

SEV_IMPL_GLOBAL

int main(int, char**)
{
    MyApp app;
    return app.run();
}
  • How to End MyApp
// call "void NetApplication::stop()"
stop();
  • Thread
class MyThread : public NetThread
{
protected:
    bool onInit() override
    {
        NetThread::onInit();

        // Your initialization code here.

        return true;
    }

    void onExit() override
    {
        // Your deinitialization code here.

        NetThread::onExit();
    }
};
// Start
MyThread* myThread = new MyThread();
myThread->start();
// End
myThread->stop();
myThread->wait();
delete myThread;
  • Event Send/Receive
// Declare MyEvent
// <Unique Id, ParamType1, ParamType2, ...>
typedef UserEvent<1, int, std::string> MyEvent;
// Send (to another thread or self)
int param1 = 20;
std::string param2 = "data";
myThread->post(new MyEvent(param1, param2));
// Receive
setUserEventHandler<MyEvent>([&](const MyEvent* myEvent) {
    int param1;
    std::string param2;
    myEvent->getParams(param1, param2);
});
  • Async Task
myThread->post([&]() {
    // Executed on myThread.
});
  • Timer
Timer* timer = new Timer();

uint32_t msec = 60000;
bool repeat = false;

// start
timer->start(msec, repeat, [&](Timer*) {
    // Called from the same thread when time out.
});
  • Network
    Please see the files under subevent/examples/ directory.
    To build on Linux.
    In each directory:
$ cmake .
$ make

TODO

  • HTTP/2
  • etc
Popular Network Projects
Popular Event Driven Projects
Popular Networking Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
C Plus Plus
Network
Http
Websocket
Thread
Tcp
Udp
Https
Openssl
Header Only
Event Driven