GithubHelp home page GithubHelp logo

oniisancr / webserver Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 30 KB

采用非阻塞套接字、epoll和kqueue的IO复用,实现基本网页服务器

CMake 6.24% C++ 93.38% HTML 0.38%
epoll kqueue threadpool

webserver's Introduction

webserver

Try to create a web server using C++.

  • 结构:

    • EventHandler类,处理客户端业务逻辑。由ThreadPool线程池管理。
    • Simpoller类,抽象出epoll、kqueue的共同接口,经过条件编译,选择epoll或kqueue,实现跨平台。
    • sockets文件夹下类,是对socket不同阶段的封装。
  • 特点:

    • 使用Epoll、kqueue实现IO复用
    • 使用边缘触发、非阻塞socket
    • 使用线程池处理业务逻辑
    • 对socket进行封装,可复用代码
  • 问题:

    • 仅支持GET方法,可对simpleweb类重新编写
    • 使用tcp的短链接,即每一次处理完就关闭该连接,不能多次交互。
      • 可删除EventHandler类中关闭连接,另外在线程池中增加对socket超时的关闭连接。
    • 项目出于对方法的学习,未从顶层设计。结构稍显混乱。
  • reference:

webserver's People

Contributors

oniisancr avatar

Watchers

 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.