C++ based Linux lightweight Web server

C++ based Linux lightweight Web server

2022-10-19 0 698
Resource Number 46045 Last Updated 2025-02-24
¥ 0USD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

This issue recommends an open source C++ Web server – TinyWebServer.

C++ based Linux lightweight Web server插图

TinyWebServer is an open source C++ lightweight Web server, which is very suitable for beginners to quickly practice network programming and build their own servers.

Feature

  • Concurrency model using thread pool + non-blocking socket + epoll(implemented by both ET and LT) + event handling (implemented by both Reactor and simulated Proactor)
  • Use state machine to parse HTTP request messages, support parse GET and POST requests
  • Access to server database to achieve web side user registration and login functions, can request server pictures and video files
  • Implement synchronous/asynchronous logging system to record the running status of the server
  • Webbench stress test can achieve tens of thousands of concurrent connection data exchange

Frame

C++ based Linux lightweight Web server插图1

Demo

Registration presentation

C++ based Linux lightweight Web server插图2

Login presentation

C++ based Linux lightweight Web server插图3

< p data – track = “31” > < strong > request image presentation (6 m) < / strong > < / p >

64708bc09a16403f8f5c68cca7ded9f5noop.image_

< p data – track = “36” > < strong > request video file demo (39 m) < / strong > < / p >

d989064bfbb84d668c31385481b2fc7cnoop.image_

Pressure test

After closing the log, use Webbench to perform a stress test on the server. Using ET and LT modes respectively, listenfd and connfd can achieve tens of thousands of concurrent connections. The test results after combining the two modes are listed below.

  • Total number of concurrent connections: 10500
  • Server access time: 5s
  • All accesses were successful

Proactor, LT + LT, 93251 QPS

0f3f74c21dae472a85d1f1579bdc9891noop.image_

Proactor, LT + ET, 97459 QPS

8f1be9ffbfb44a79bf4a361ddcd35f98noop.image_

Proactor, ET + LT, 80498 QPS

e1e3c67817da48c98b439d2fa7665868noop.image_

Proactor,ET + ET,92167 QPS

5c013e0be9ef4f62824b4f5c81ce55b8noop.image_

Reactor,LT + ET,69175 QPS

C++ based Linux lightweight Web server插图10C++ based Linux lightweight Web server插图11C++ based Linux lightweight Web server插图12C++ based Linux lightweight Web server插图13C++ based Linux lightweight Web server插图14

Note: When using the webbench of this project for pressure test, if an error indicates that the webbench command cannot be found, delete the executable file webbench and recompile it.

Source code download

There are currently two versions, and the code structure between the versions has been greatly changed, and the documentation and code running methods are also inconsistent. The refactored version is more concise, and the original version (raw_version) retains the original flavor of the double code, and it is easier to start from the original version.

If you encounter a failure to download github code, or if access is too slow, you can download it from the following link to synchronize with the latest Github submission.

github: https://github.com/qinguoyi/TinyWebServer
 Reconstructed version download address: https://pan.baidu.com/share/init?surl=PozKji8Oop-1BYcfixZR0g

Extract code: vsqq
 Original version raw_version https://pan.baidu.com/share/init?surl=asMNDW-zog92DZY1Oa4kaQ

Extract code: 9wye

Fast running

Server test environment

  • Ubuntu version 16.04
  • MySQL version 5.7.29

Browser test environment

  • Windows and Linux
  • Chrome
  • FireFox
  • No test for other browsers

Verify that MySQL database is installed before testing

// Build yourdb library
create database yourdb;

// Create the user table
USE yourdb;
CREATE TABLE user(
    username char(50) NULL,
    passwd char(50) NULL
)ENGINE=InnoDB;

// Add data
INSERT INTO user(username,  passwd) VALUES('name',  'passwd'); 

Modify database initialization information in main.cpp

// Database login, password, library name 
string user = "root";
string passwd = "root";
string databasename = "yourdb"; 

build

sh ./build.sh

Start server

./server

Browser

ip:9006

—END—

Open Source protocol: Apache2.0

Open source address:
https://github.com/qinguoyi/TinyWebServer

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free source code C++ based Linux lightweight Web server https://ictcoder.com/kyym/c-based-linux-lightweight-web-server.html

Share free open-source source code

Q&A
  • 1, automatic: after taking the photo, click the (download) link to download; 2. Manual: After taking the photo, contact the seller to issue it or contact the official to find the developer to ship.
View details
  • 1, the default transaction cycle of the source code: manual delivery of goods for 1-3 days, and the user payment amount will enter the platform guarantee until the completion of the transaction or 3-7 days can be issued, in case of disputes indefinitely extend the collection amount until the dispute is resolved or refunded!
View details
  • 1. Heptalon will permanently archive the process of trading between the two parties and the snapshots of the traded goods to ensure that the transaction is true, effective and safe! 2, Seven PAWS can not guarantee such as "permanent package update", "permanent technical support" and other similar transactions after the merchant commitment, please identify the buyer; 3, in the source code at the same time there is a website demonstration and picture demonstration, and the site is inconsistent with the diagram, the default according to the diagram as the dispute evaluation basis (except for special statements or agreement); 4, in the absence of "no legitimate basis for refund", the commodity written "once sold, no support for refund" and other similar statements, shall be deemed invalid; 5, before the shooting, the transaction content agreed by the two parties on QQ can also be the basis for dispute judgment (agreement and description of the conflict, the agreement shall prevail); 6, because the chat record can be used as the basis for dispute judgment, so when the two sides contact, only communicate with the other party on the QQ and mobile phone number left on the systemhere, in case the other party does not recognize self-commitment. 7, although the probability of disputes is very small, but be sure to retain such important information as chat records, mobile phone messages, etc., in case of disputes, it is convenient for seven PAWS to intervene in rapid processing.
View details
  • 1. As a third-party intermediary platform, Qichou protects the security of the transaction and the rights and interests of both buyers and sellers according to the transaction contract (commodity description, content agreed before the transaction); 2, non-platform online trading projects, any consequences have nothing to do with mutual site; No matter the seller for any reason to require offline transactions, please contact the management report.
View details

Related Article

make a comment
No comments available at the moment
Official customer service team

To solve your worries - 24 hours online professional service