wlgq2 / Uv Cpp
Licence: mit
libuv wrapper in C++11 /libuv C++11网络库
Stars: ✭ 480
Projects that are alternatives of or similar to Uv Cpp
jwEngine
A cross-platform C++<->lua server quick solution
Stars: ✭ 226 (-52.92%)
Mutual labels: tcp, libuv
ccxx
This is a cross-platform library software library about c, c ++, unix4, posix. Include gtest, benchmark, cmake, process lock, daemon, libuv, lua, cpython, re2, json, yaml, mysql, redis, opencv, qt, lz4, oci ... https://hub.docker.com/u/oudream
Stars: ✭ 31 (-93.54%)
Mutual labels: tcp, libuv
Networksocket
NetworkSocket是一个以中间件(middleware)扩展通讯协议,以插件(plug)扩展服务器功能的支持SSL安全传输的通讯框架;目前支持http、websocket、fast、flex策略与silverlight策略协议。
Stars: ✭ 435 (-9.37%)
Mutual labels: tcp
Fpga Network Stack
Scalable Network Stack for FPGAs (TCP/IP, RoCEv2)
Stars: ✭ 345 (-28.12%)
Mutual labels: tcp
Message Io
Event-driven message library for building network applications easy and fast.
Stars: ✭ 321 (-33.12%)
Mutual labels: tcp
Udp2raw Tunnel
A Tunnel which Turns UDP Traffic into Encrypted UDP/FakeTCP/ICMP Traffic by using Raw Socket,helps you Bypass UDP FireWalls(or Unstable UDP Environment)
Stars: ✭ 4,839 (+908.13%)
Mutual labels: tcp
Networker
A simple to use TCP and UDP networking library for .NET. Compatible with Unity.
Stars: ✭ 408 (-15%)
Mutual labels: tcp
Mobileimsdk
一个原创移动端IM通信层框架,轻量级、高度提炼,历经8年、久经考验。可能是市面上唯一同时支持UDP+TCP+WebSocket三种协议的同类开源框架,支持iOS、Android、Java、H5,服务端基于Netty。
Stars: ✭ 3,864 (+705%)
Mutual labels: tcp
Cnp3
Computer Networking : Principles, Protocols and Practice (first and second edition, third edition is being written on https://github.com/cnp3/ebook)
Stars: ✭ 471 (-1.87%)
Mutual labels: tcp
Goben
goben is a golang tool to measure TCP/UDP transport layer throughput between hosts.
Stars: ✭ 391 (-18.54%)
Mutual labels: tcp
uv-cpp
Language Translations:
uv-cpp is a simple interface, high-performance network library based on C++11.
Dependencies
Features
- C++11 functional/bind style callback instead of C-style function pointer.
-
TCP
andUDP
wrapper. -
DNS
andHttp
:DNS query and http support,Http routing based on radix tree. -
Timer
andTimerWheel
:Heartbeat timeout judgment with time complexity of O(1). -
Async
:libuv async wrapper,but optimized the problem of calling multiple times but callback will only be called once. -
Packet
andPacketBuffer
:Send and receive packet of Tcp data stream. Support custom data packet structure (such as uvnsq) - Log interface.
Build Instructions
- VS2017 (windows)
- Codeblocks (linux)
- CMake (linux)
Benchmark
ping-pong VS boost.asio-1.67
environment:Intel Core i5 8265U + debian8 + gcc8.3.0 + libuv1.30.0 + '-O2'
size peer pack | 1K bytes | 2K bytes | 4K bytes | 8K bytes |
---|---|---|---|---|
uv-cpp | 16138 kbyte | 32071 kbyte | 59264 kbyte | 123813 kbyte |
boost.asio | 16119 kbyte | 31566 kbyte | 58322 kbyte | 126210 kbyte |
environment:i5-8265U + 4G memory + 4k bytes ping-pong
concurrency| 10|100|1000|5000|
:---------:|:--------:|:--------:|:--------:|:--------:|
uv-cpp | 654282 kbyte|591869 kbyte|401500 kbyte|412855 kbyte|
boost.asio | 633818 kbyte|585716 kbyte|371386 kbyte|382402 kbyte|
Apache bench VS nginx-1.14.2
environment:Intel Core i5 8265U + debian8 + gcc8.3.0 + libuv1.30.0 + '-O2'
1000 concurrency && 100000 request.
Quick start
A simple echo server
#include <iostream>
#include <uv/include/uv11.h>
int main(int argc, char** args)
{
uv::EventLoop* loop = uv::EventLoop::DefaultLoop();
uv::TcpServer server(loop);
server.setMessageCallback([](uv::TcpConnectionPtr ptr,const char* data, ssize_t size)
{
ptr->write(data, size, nullptr);
});
//server.setTimeout(60); //heartbeat timeout.
uv::SocketAddr addr("0.0.0.0", 10005, uv::SocketAddr::Ipv4);
server.bindAndListen(addr);
loop->run();
}
A simple http service router which based on radix tree.
int main(int argc, char** args)
{
uv::EventLoop loop;
uv::http::HttpServer::SetBufferMode(uv::GlobalConfig::BufferMode::CycleBuffer);
uv::http::HttpServer server(&loop);
//example: 127.0.0.1:10010/test
server.Get("/test",std::bind(&func1,std::placeholders::_1,std::placeholders::_2));
//example: 127.0.0.1:10010/some123abc
server.Get("/some*",std::bind(&func2, std::placeholders::_1, std::placeholders::_2));
//example: 127.0.0.1:10010/value:1234
server.Get("/value:",std::bind(&func3, std::placeholders::_1, std::placeholders::_2));
//example: 127.0.0.1:10010/sum?param1=100¶m2=23
server.Get("/sum",std::bind(&func4, std::placeholders::_1, std::placeholders::_2));
uv::SocketAddr addr("127.0.0.1", 10010);
server.bindAndListen(addr);
loop.run();
}
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].