GithubHelp home page GithubHelp logo

swhgoon / uwebsockets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unetworking/uwebsockets

1.0 2.0 0.0 1.58 MB

Tiny WebSockets

Home Page: http://uws.chat

License: zlib License

Makefile 1.72% C++ 93.94% Go 0.41% Shell 0.04% JavaScript 3.20% Batchfile 0.31% QMake 0.39%

uwebsockets's Introduction

`µWS` is one of the most lightweight, efficient & scalable WebSocket & HTTP server implementations available. It features an easy-to-use, fully async object-oriented interface and scales to millions of connections using only a fraction of memory compared to the competition. While performance and scalability are two of our top priorities, we consider security, stability and standards compliance paramount. License is zlib/libpng (very permissive & suits commercial applications).
  • Autobahn tests all pass.
  • One million WebSockets require ~122mb of user space memory (112 bytes per WebSocket).
  • By far one of the fastest in both HTTP and WebSocket throughput (see table below).
  • Linux, OS X, Windows & Node.js support.
  • Runs with raw epoll, libuv or ASIO (C++17-ready).
  • Valgrind & AddressSanitizer clean.
  • Permessage-deflate, SSL/TLS support & integrates with foreign HTTP(S) servers.
  • Multi-core friendly.

Simple & modern

The interface has been designed for simplicity and only requires you to write a few lines of code to get a working server:

#include <uWS/uWS.h>

int main() {
    uWS::Hub h;

    h.onMessage([](uWS::WebSocket<uWS::SERVER> ws, char *message, size_t length, uWS::OpCode opCode) {
        ws.send(message, length, opCode);
    });

    h.onHttpRequest([](uWS::HttpResponse *res, uWS::HttpRequest req, char *data, size_t length, size_t remainingBytes) {
        res->end(const char *, size_t);
    });

    h.listen(3000);
    h.run();
}

Get the sources of the uws.chat server here. Learn from the tests here.

Widely adopted

Not your average server

µWS was designed to perform well across the board, not just in one specific dimension. With excellent memory usage paired with high throughput it outscales Socket.IO by 180x.

Benchmarks are run with default settings in all libraries, except for ws which is run with the native performance addons. Read more about the benchmarks here.

Getting started

Dependencies

First of all you need to install the required dependencies. This is very easily done with a good open source package manager like Homebrew for OS X, vcpkg for Windows or your native Linux package manager.

Always required:

  • OpenSSL 1.0.x
  • zlib 1.x

Not required on Linux systems:

  • libuv 1.3+
  • Boost.Asio 1.x

On Linux systems you don't necessarily need any third party event-loop library, but can run directly on the high performance epoll backend (this gives by far the best performance and memory usage). Non-Linux systems will automatically fall back to libuv.

If you wish to integrate with a specific event-loop you can define USE_ASIO or USE_LIBUV as a global compilation flag and then link to respective libraries.

Compilation

Clone and enter the repo:

  • git clone https://github.com/uWebSockets/uWebSockets.git && cd uWebSockets
OS X & Linux

Compile with Make:

  • make
  • sudo make install
Windows

Compile with Visual C++ Community Edition 2015 or later. This workflow requires previous usage of vcpkg:

  • vcpkg integrate install
  • vcpkg install libuv:x64-windows boost:x64-windows openssl:x64-windows zlib:x64-windows
  • Open the VC++ project file
  • If you see a toolset upgrade prompt (i.e. you're using VS 2017), accept it
  • Click Build

uwebsockets's People

Contributors

agauniyal avatar benv avatar capaj avatar chemhack avatar deckerrj avatar devsnek avatar dkelson avatar dvergeylen avatar ewak avatar florianbellazouz avatar hpohl avatar jgilje avatar jimmyt857 avatar jnschulze avatar kapouer avatar lb-- avatar lordmajestros avatar lpinca avatar merghq avatar not-implemented avatar oresoftware avatar peters avatar qwename avatar ras0219-msft avatar silverwind avatar unetworkingab avatar utensil avatar vinniefalco avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.