1 Star 1 Fork 0

xiyan-100 / uWebSockets

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Zlib

µ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.

:briefcase: :tophat: If you like what you see then kindly support me on patreon above or simply hire me, I'm not doing anything right now. Toss me a mail at alexhultman@gmail.com and we can discuss this further - only companies please, no 1-day private consulting jobs etc.

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

While I cannot use their logo, Google Creative Labs has published a multiplayer WebVR demo using µWS over 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.
Copyright (c) 2016 Alex Hultman and contributors This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgement in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.

简介

Tiny WebSockets :microscope: 展开 收起
C++
Zlib
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/xiyan100/uWebSockets.git
git@gitee.com:xiyan100/uWebSockets.git
xiyan100
uWebSockets
uWebSockets
master

搜索帮助