Coder Social home page Coder Social logo

anet's Introduction

ANet

基于Redis网络模型的简易网络库,网络模块代码取自Redis源码。

Redis网络模型介绍

Redis网络模型是一个使用IO多路复用单线程非阻塞的模型。这个模型的优点在于单线程不用考虑加锁,如果在单核环境上可以将效率发挥到最大。

如何启动一个服务器

  • 通过aeCreateEventLoop创建核心aeEventLoop
  • 通过anetTcpServer完成socket() bind() listen()
  • 通过aeCreateFileEventfd注册相应的事件
  • aeMain循环检测每个fd是否有事件发生,如果有就交给相应的读/写处理程序。

附:各个文件介绍

文件 作用
ae.c ae.h ae_epoll.c ae_select.c Redis事件处理器的实现(Redis源码)
anet.c anet.h Redis网络库的实现(Redis源码)
buffer.c buffer.h 自行实现的buffer
protocol.c protocol.h 自行定义协议
define.h 一些常量,比如listen的backlog大小
server.c server_test.c 自定义的服务端和客户端程序

anet's People

Contributors

hurley25 avatar yangbodong22011 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  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.