Giter Site home page Giter Site logo

praveenmunagapati / uwebsockets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unetworking/uwebsockets

0.0 2.0 0.0 2.39 MB

Tiny WebSockets

Home Page: https://www.youtube.com/watch?v=63OyhcOnEaY

License: zlib License

Makefile 1.45% C++ 97.37% Go 0.47% Shell 0.05% JavaScript 0.23% QMake 0.44%

uwebsockets's Introduction

Do NOT treat the issue tracker like a chat. Do NOT post new questions. Do NOT post non-bugs. You are NOT the only user. I will NOT personally debug your INCOMPETENCE. Build errors are NOT bugs. Do NOT post build errors of any kind.

µ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 ~111mb of user space memory (104 bytes per WebSocket).
  • Single-threaded throughput of up to 5 million HTTP req/sec or 20 million WebSocket echoes/sec.
  • 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 & optionally thread-safe via compiler flag UWS_THREADSAFE.

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);
    });

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

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

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.

Perfect for WebRTC

Distributed WebRTC networks typically employ WebSockets for peer signalling. Since every single peer in the entire distributed network requires a persistent connection to the signalling server at all times, only a scalable WebSocket server will do.

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.

  • OpenSSL 1.x.x
  • zlib 1.x
  • libuv 1.3+ or Boost.Asio 1.x (both optional on Linux)

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. USE_EPOLL is default on Linux while other systems default to USE_LIBUV.

  • Fedora: sudo dnf install openssl-devel zlib-devel
  • Homebrew: brew install openssl zlib libuv
  • Vcpkg: vcpkg install openssl zlib libuv and/or vcpkg install openssl:x64-windows zlib:x64-windows libuv:x64-windows

Compilation

OS X & Linux
  • make
  • sudo make install (or as you wish)
Windows
  • Compile VC++.vcxproj with Visual C++ Community Edition 2015 or later.

uwebsockets's People

Contributors

unetworkingab avatar agauniyal avatar lpinca avatar kapouer avatar silverwind avatar utensil avatar jimmyt857 avatar chemhack avatar jgilje avatar oresoftware avatar qwename avatar not-implemented avatar mingc00 avatar lb-- avatar jnschulze avatar peters avatar deckerrj avatar ras0219-msft avatar vinniefalco avatar ymikhailov avatar ewak avatar florianbellazouz avatar zhanglix avatar mkozjak avatar saper avatar voultapher avatar capaj avatar merghq avatar hpohl avatar devsnek avatar

Watchers

James Cloos 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.