Giter Club home page Giter Club logo

cpp11_muduo's Introduction

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处理代码及测试样例 :

在这里插入图片描述

cpp11_muduo's People

Contributors

kanade2010 avatar

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.