1 Star 0 Fork 0

teddyxiong53 / cpp11_muduo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

cpp11_muduo

c++11 implementation of muduo net lib and muduo asynclogging.

original author github: https://github.com/chenshuo/muduo

整理的muduo网络库的c++11版

因为SimpleMuduo不是稳定版,于是新建了一个仓库维护下这个c++11版。 小bug会在这里修复,SimpleMuduo不再更新,有兴趣的话可以一起维护一下。

在这里插入图片描述

#include <async_logging>
#include <muduo_server>

void on_connection(const muduo::TcpConnectionPtr& conn){
  LOG_DEBUG << "new conn from " << conn->peerAddress().toIpPort();
}

void on_message(const muduo::TcpConnectionPtr& conn, muduo::Buffer* buffer, ssize_t len){
  LOG_DEBUG << "on message : " << len << " bytes " << buffer->peek();
  buffer->retrieve(len);
}

int main(){

  Logger::setLogLevel(Logger::DEBUG);

  muduo::EventLoop loop;

  InetAddress localAddr(8080);
  muduo::TcpServer tcp_server(&loop, localAddr);

  tcp_server.setConnectionCallBack(std::bind(on_connection, std::placeholders::_1));
  tcp_server.setMessageCallBack(std::bind(on_message, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
  //tcp_server.setCloseCallBack(std::bind(on_close, std::placeholders::_1));
  tcp_server.start();

  loop.loop();

  getchar();
}

Alt text

-------------------2019/4/30

添加http处理代码及测试样例 :

在这里插入图片描述

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/teddyxiong53/cpp11_muduo.git
git@gitee.com:teddyxiong53/cpp11_muduo.git
teddyxiong53
cpp11_muduo
cpp11_muduo
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891