Skip to content

Mevent is a tiny HTTP/WebSocket server library, can be used on Linux and OSX.

License

Notifications You must be signed in to change notification settings

xkilluax/mevent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mevent

GitHub license Build Status

Mevent is a tiny HTTP/WebSocket server library, can be used on Linux and OSX.

Features

  • TLS (https/wss) support
  • ping/pong support
  • Asynchronous and non-blocking, I/O Multiplexing using epoll and kqueue
  • Supports Linux, OSX
  • Thread-safe

Integration

You should have libssl, libcurl installed into your system, and your compiler should support C++11.

Debian and Ubuntu users

apt-get install libssl-dev libcurl4-gnutls-dev

Fedora and RedHat users

yum install openssl-devel libcurl-devel

OSX users

brew update
brew install openssl curl

Example

#include "mevent/http_server.h"

using namespace mevent;

class HelloWorld {
public:
    void Index(Connection *conn) {
        conn->Resp()->SetHeader("Content-Type", "text/html");
        conn->Resp()->WriteString("hello world!");
    }
};

int main() {
    HelloWorld hello;
    
    HTTPServer *server = new HTTPServer();
    server->SetHandler("/", std::bind(&::HelloWorld::Index, &hello, std::placeholders::_1));

    server->SetWorkerThreads(4);
    server->SetIdleTimeout(60);
    server->SetMaxWorkerConnections(8192);
    
    server->ListenAndServe("0.0.0.0", 80);
    
    return 0;
}

More examples can be found in examples directory.

Author

Luyao Teng

About

Mevent is a tiny HTTP/WebSocket server library, can be used on Linux and OSX.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published