Git Product home page Git Product logo

netplus / netplus Goto Github PK

View Code? Open in Web Editor NEW
69.0 4.0 17.0 29.43 MB

An easy-to-learn, high performance network io library written in modern cpp (c++11), It borrows concepts from Netty, and with well defined internal modules, It enables you to write rpc, http/https,websocket application with just few lines。

License: MIT License

C 20.86% Makefile 7.09% C++ 45.32% Batchfile 0.01% Pascal 0.05% CMake 1.00% Python 0.01% M4 6.06% Shell 16.88% Roff 2.66% Awk 0.02% Perl 0.03% NASL 0.01% HTML 0.01%
rpc-library socket-programming http websocket network-library https tls

netplus's Introduction

A new beginning of network programming

What is Netplus

Netplus is a network programming library written in c++11. It's highly extensible, and with default configuration it can reach high performance. It's easy to learn. Basically, you can just implement your own business in a channel handler, then the library would do all the dirty work (platform specific considerations, io event delivery&process, basic memory optimization, etc ) for you. You can also write http/https,websocket,based application even you only have little corresponding knowledge background, Cuz it has relevant modules to simplify programming tasks of such kinds. Netplus borrows lots of concepts from Netty, and tries to implement these concepts by c++, such as channel, channel handler, channel pipeline, executor, scheduler, promise. Any one who is familiar with Netty should be able to start with ease.

What can we use Netplus to do

1) Implement a message gateway
2) Use as the network component of a message queue, gameserver or any other network based application.
   please note that netplus is not a gameserver framework, But you can implement one with netplus
3) Implement protocol driver of Middleware, such as kinds of database, message queue server, etc
4) Implement http/https, websocket based application
5) Implement RPC server

Target Arch & Platform

1) Windows on x86/x64
2) Linux on x86/x64/arm
3) IOS/MAC on x86/arm
4) Android on x86/arm

First Impression

//listen on 0.0.0.0:80 port for a http service, 
netp::listen_on("tcp://0.0.0.0:80", [](NRP<netp::channel> const& ch) {
    ch->pipeline()->add_last(netp::make_ref<netp::handler::http>());
    ...
}

//fast request for a http request
NRP<netp::http::request_promise> rp = netp::http::get("https://x.com/");

//listen on 10088 for a rpc service
netp::rpc::listen("tcp://0.0.0.0:10088",[](NRP<netp::rpc> const& r){
   r->bindcall( api_id, []( NRP<netp::rpc> const& r, NRP<netp::packet> cosnt& in, NRP<netp::rpc_call_promise> const& rcp ) {
       NETP_INFO("[rpc]a request in, request pkt len: %u", in->len() );
       NRP<netp::packet> reply = netp::make_ref<netp::packet>();
       reply->write("this is a reply from the call to api_id");
       
       //call return with netp::OK, and a message in reply pkt
       rcp->set(std::make_tuple(netp::OK, reply));
   });
},...);

Learn more from the following urls:

Build and usage: https://github.com/netplus/netplus/wiki#building--usage

Quick Start: https://github.com/netplus/netplus/wiki#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B

Benchmark: https://github.com/netplus/netplus/wiki#benchmark

Examples: https://github.com/netplus/netplus/wiki#examples

Basic concept: https://github.com/netplus/netplus/wiki#concept

Modules: https://github.com/netplus/netplus/wiki#modules

Zhihu: https://www.zhihu.com/column/c_1339539434091040768

Others

QQ group: 576499184 (加群请注明来源,thx)

netplus's People

Contributors

cainiaodj avatar netplus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

netplus's Issues

Netplus failed to build with error C1083: Cannot open include file: 'netp/core/compiler/msvc__NETP_ARCH_STR_.hpp' and C1189: #error: "Platform not supported!" with MSVC on windows

Netplus failed to build with error C1083: Cannot open include file: 'netp/core/compiler/msvc__NETP_ARCH_STR_.hpp' and C1189: #error: "Platform not supported!" with MSVC on windows. It can reproduces on version 5db9e3a. Could you please help look at this issue? Thank you very much

Environment
Compiler version: VS2019 (16.11.9)
Operating system: Windows server 2019

Steps to reproduce:

  1. open VS2019 x64 tools command
  2. git clone https://github.com/netplus/netplus F:\netplus
  3. cd F:\netplus\projects\cmake
  4. "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=arm64
  5. mkdir build_arm64 & cd build_arm64
  6. cmake -G "Visual Studio 16 2019" -A arm64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 ..
  7. msbuild /m /p:Platform=arm64 /p:Configuration=Release netplus.sln /t:Rebuild

Build.log:
msbuild.log

Error info:
5>F:\netplus\projects\cmake....\include\netp/core/compiler.hpp(98,10): fatal error C1083: Cannot open include file: 'netp/core/compiler/msvc__NETP_ARCH_STR_.hpp': No such file or directory (d:\a01_work\3\s\src\vctools\Compiler\CxxFE\sl\p1\c\p0prepro.c:1968) [F:\netplus\projects\cmake\build_arm64\netplus.vcxproj]
5>F:\netplus\3rd\stack_walker\StackWalker.cpp(1194,1): fatal error C1189: #error: "Platform not supported!" [F:\netplus\projects\cmake\build_arm64\netplus.vcxproj]

Netplus failed to build due to "fatal error C1083: Cannot open include file: 'ares_build.h': No such file or directory" on x86 and x64 configuration with MSVC on windows

Describe the bug
Netplus failed to build due to "fatal error C1083: Cannot open include file: 'ares_build.h': No such file or directory" on x86 and x64 configuration with MSVC on windows. Could you please help look at this issue or provide some workarounds? Thanks in advance.

To Reproduce

  1. git clone https://github.com/netplus/netplus F:\gitP\musescore\MuseScore
  2. mkdir F:\gitP\netplus\netplus\projects\cmake\build_amd64
  3. cd F:\gitP\netplus\netplus\projects\cmake\build_amd64
  4. set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=amd64
  5. cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 .. 2>&1
  6. msbuild /m /p:Platform=x64 /p:Configuration=Release netplus.sln /t:Rebuild 2>&1

Error Message
"F:\gitP\netplus\netplus\projects\cmake\build_amd64\netplus.sln" (Rebuild target) (1) ->
       "F:\gitP\netplus\netplus\projects\cmake\build_amd64\netplus.vcxproj.metaproj" (Rebuild target) (3) ->
       "F:\gitP\netplus\netplus\projects\cmake\build_amd64\netplus.vcxproj" (Rebuild target) (5) ->
       (ClCompile target) ->
         F:\gitP\netplus\netplus\3rd\c-ares\c-ares-1.18.1\src\lib\ares_setup.h(83,10): fatal error C1083: Cannot open include file: 'ares_build.h': No such file or directory (D:\a01_work\2\s\src\vctools\Compiler\CxxFE\sl\p1\c\p0prepro.c:1934) [F:\gitP\netplus\netplus\projects\cmake\build_amd64\netplus.vcxproj]

    11 Warning(s)
    1 Error(s)

Expected behavior
Build successfully.

Setup
VS 2019 + Windows Server 2019

Additional context
build.log
log

rpc: optimize request list

1, We have to check the requested call and see whether the request has expired a duration.
2, For each reply from server, we have to lookup through a container (list for now) to get the original request call

Right now, we use a requested list to achieve the above goal, the lookup cost is o(n), It might be better to optimize the list to a hash based circular buf.

enable tls support

if we pass --with-botan option by cmake command, tls features would be available, affacted handler are websocket/http

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.