Network Programming (5) IO Multiplexing — epoll

1. Concept The full name of epoll is eventpoll, a notification mechanism based on event triggering. When the file descriptor read buffer is not empty, the read event is triggered. When the file descriptor write buffer is writable, the write event is triggered. 2. Principle The core data structure of epoll is: a red-black tree […]

[IO multiplexing] How EPOLL implements ET (edge trigger)

LT and ET edge-triggered What is edge triggering How to implement edge triggering Summary & Notes How to use recv & send for edge triggering recv return value of recv send level-trggered horizontal trigger code When we are doing epoll network programming, we can choose LT (horizontal trigger) or ET (edge trigger). By default, epoll […]

Network IO and IO multiplexing (select/poll/epoll) (1)

Tip: After the article is written, the table of contents can be automatically generated. For how to generate it, please refer to the help document on the right. Network IO and IO multiplexing (select/poll/epoll) (1) Preface 1. Network card 2. Network IO 1.Code Replenish 2. Use tcp/udp net assistant tool 3. Implement communication between the […]

Multiplexing (Part 1) – select

Table of Contents 1. Select interface 1. Understand the select system call 2. Understanding of each parameter 2. Write select server 1. Two tool categories 2. Network socket encapsulation 3. Server class writing 4. Source file writing 5. Run 1. select interface 1. Understand the select system call int select(int nfds, fd_set readfds, fd_set writefds, […]

[Linux Programming] Five IO models of Linux: blocking IO, non-blocking IO, IO multiplexing, signal-driven IO and asynchronous IO

The Linux IO model refers to the way in which user processes and the kernel perform input and output operations in a Linux system. Input and output operations usually involve the transmission and copying of data. These operations consume system resources and time. Therefore, choosing an appropriate IO model is very important to improve the […]

io multiplexing select, poll, epoll model

1. Select model 1. Meaning of function parameters int select(int maxfd,fd_set *rset,fd_set *wset,fd_set *eset,struct timeval *timeout); Copy the fd_set set (parameters 2, 3, and 4) that need to be detected to the kernel. If there is io ready, clear the fd_set set, reset the fd_set set, and then copy it to the user layer. Parameter […]

muduo source code analysis of poller/EpollPoller multiplexing class

Introduction Poller is an abstract virtual base class of the I/O multiplexing interface, which encapsulates the I/O multiplexing API. Muduo provides EPollPoller and PollPoller derived classes (epoll and poll), so select is not supported. newDefaultPoller() selects epoll by default Main interface poll It is the core function of Poller. Use poll or epoll_wait of derived […]

Driver development 5 blocking IO instances, IO multiplexing

1 blocking IO Process 1 #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <string.h> int main(int argc, char const *argv[]) { char buf[128] = {0}; int a,b; int fd = open(“/dev/myled0”,O_RDWR); if(fd < 0) { printf(“Failed to open device file\ “); exit(-1); } while(1) { memset(buf,0,sizeof(buf)); read(fd,buf,sizeof(buf)); printf(“buf:%s\ […]

Linux IO multiplexing (advanced character device 3)

1. Introduction to IO multiplexing in Linux IO multiplexing is a synchronous IO model. IO multiplexing allows one process to monitor multiple file descriptors. Once a file descriptor is ready, the application is notified to perform corresponding read and write operations. When no file descriptors are ready, the application blocks, freeing up CPU resources. At […]

Linux network programming – IO multiplexing

IO multiplexing IO multiplexing is a very useful technique that allows a single thread/process to monitor and manage multiple IO descriptors simultaneously. It is particularly suitable for scenarios that need to handle a large number of concurrent socket connections, such as web servers, database servers, or other network applications. IO multiplexing allows applications to wait […]