µ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).
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.
µ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.
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.
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.
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
.
sudo dnf install openssl-devel zlib-devel
brew install openssl zlib libuv
vcpkg install openssl zlib libuv
and/or vcpkg install openssl:x64-windows zlib:x64-windows libuv:x64-windows
make
sudo make install
(or as you wish)VC++.vcxproj
with Visual C++ Community Edition 2015 or later.此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。