1. Synchronous and asynchronous logs Sync log: Synchronous logging refers to writing the log to a file at the same time it is generated. The advantage of this method is that it is simple in design and can output the log to the file in a timely manner. The disadvantage is that it will frequently […]
Tag: webserver
.netcore windows app starts webserver
Create controller: using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.Json.Serialization; using System. Threading. Tasks; namespace MyWorker.Controller { [ApiController] [Route(“/api/[controller]”)] public class HomeController { public ILogger<HomeController> logger; public HomeController(ILogger<HomeController> logger) { this. logger = logger; } public string Echo() { return DateTime.Now.ToString(“yyyy-MM-dd HH:mm:ss”); } } } define webserver using System; […]
Webserver–The principle of thread pool, handwritten thread pool
Directory 1. What is a thread pool? 2. The role of the thread pool 3. Design of task queue 4. Constructor 5. Push interface design 6. The execution function of the child thread 7. Destructor 8. Test thread pool 9. Setting the number of threads in the thread pool 1. Experience points 2. Optimal number […]
Industrial Data Acquisition Project Based on WebServer
The ultimate goal of this project is to read and control the information of the Modbus device (slave simulation is used here) through the operation of the webpage. main idea: When the browser sends a dynamic data request to the web server through the http protocol, the main process of the web server will Fork […]
Industrial Data Acquisition Project Based on WebServer
Note: The training project is only for recording and sharing the process and experience of writing the project, and has no other purpose. 1. Diagram of project realization The project mainly needs to solve the connection between the web server WebServer and the service program. In order to achieve the connection, a “middleman” CGI is […]
C language implements WebServer server based on Linux, epoll and multithreading
Code structure: Server.h The header file declares the function #pragma once #include <stdio.h> // Create a new socket file descriptor for TCP monitoring and return int initListenFd(unsigned short port); // start epoll int epollRun(int lfd); // accept to establish a connection void* acceptClient(void* arg); // Receive http request, cfd means connection socket, epfd means epoll […]
Two, WebServer-multi-process development
Table of contents 2.1 Process Overview 01/Programs and processes A program is a file containing a series of information describing how to create a process at runtime: Binary Format Identification: Each program file contains meta-information describing the format of the executable. The kernel uses this information to interpret other information in the file. (ELF Executable […]
Industrial Data Acquisition Project Based on Webserver
Directory introduce Modbus origin Classification Advantage Application Scenario Modbus TCP Features Modbus TCP communication protocol Web server server Introduction common classification CGI Introduction Recent Understanding of CGI features common environment variables working principle http protocol Introduction features diagram train of thought sample code compile file main.c part definition message queue create Open Cyclic sending Shared […]
Webserver 04 timer handles inactive connections
It is mainly divided into two parts, one is the timing method and signal notification process, the other is the timer and its container design, timing task processing Inactive connection: After the client establishes a connection with the resume server, there is no data exchange for a long time, which will occupy the file descriptor […]
[TinyWebServer source code analysis] (1) Thread synchronization mechanism encapsulation class
This article is an analysis of the source code of tens of thousands of star projects on github, for everyone to learn and communicate project address: https://github.com/qinguoyi/TinyWebServer 1. Thread synchronization mechanism encapsulation class (lock) Thread synchronization mechanism wrapper class ================= Multi-thread synchronization ensures that only one thread can enter the critical code segment at any […]