代码拉取完成,页面将自动刷新
一个参考libhv,基于C++11的Linux服务端网络库,事件驱动IO, 欢迎使用。
Http服务
#include "Application.h"
#include "base/System.h"
#include "module/http/HttpServer.h"
using namespace SinBack;
using namespace SinBack::Module;
int main(int argc, char* argv[])
{
Base::system_signal(SIGPIPE, nullptr);
auto module = std::make_shared<Http::HttpServer>();
Http::HttpService service;
// 添加 Service
service.GET("/api/test", [](Http::HttpContext& cxt) -> Int {
return cxt.sendText("我是测试接口");
});
module->setting().keepAlive = false;
module->setting().staticFileDir = "../web";
module->addService("main", &service);
Main::Application app;
app.setting().workThreadNum = 4;
app.setting().listenPort = 2022;
app.setting().logPath = "./SinBack";
app.setModule(module);
app.run([](const String& msg){
printf("%s\n", msg.c_str());
});
return 0;
}
TCP服务:
----- base : 底层函数封装
----- core : 事件驱动核心代码
----- module : 应用层功能模块
----- tools : 一些工具函数
代码问题请发邮件:tw2938384958@gmail.com 、 2938384958@qq.com
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。