Git Product home page Git Product logo

mywebsever's Introduction

MyWebSever

Linux下C++ Web服务器,模仿牛客项目搭建属于自己的服务器.

项目功能

该项目在是在 Linux环境下使用C/C++语言开发的多线程 HTTP web 服务器,服务器支持一定数量客户端连接并及时响应,服务器返回 html、图片等文件。主要使用IO多路复用、线程池、有限状态机、定时器等技术实现。

技术要点

  • 使用 Socket 实现不同主机进程之间的网络通信;
  • 使用 Epoll 技术实现IO多路复用,提高响应效率;
  • 使用 线程池 + 非阻塞socket + epoll(ET和LT均实现) + 事件处理(Reactor和模拟Proactor均实现) 的并发模型
  • 使用状态机解析HTTP请求报文,支持解析GET和POST请求
  • 访问服务器数据库实现web端用户注册、登录功能,可以请求服务器图片和视频文件
  • 实现同步/异步日志系统,记录服务器运行状态

不同点/创新点

使用双缓冲机制改进异步日志系统;将双向链表实现的定时器改为基于小根堆的实现。

个人收获:

更加熟悉了C++、Linux、多线程、网络通信等相关知识 ;在项目开发中对 HTTP服务过程以及TCP协议有了更深的理解 ; 加深了Socket 通信以及IO多路复用的理解。

待完善的地方

  • 将数据库实现改为Redis实现
  • 加入缓存机制(LRU/LFU)
  • 添加文件上传功能,实现客户端与服务器的真正交互

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.