Netty Learning (i) a brief introduction to the network IO model under--linux

Source: Internet
Author: User
Tags epoll

The Linux kernel sees all external devices as a single file, and read and write to a file invokes the system commands provided by the kernel.

, returns a file descriptor (FD, filename descriptor). and read and write to a socket will have a corresponding descriptor, become SOCKETFD

(socket descriptor), a descriptor is a number that points to a struct in the kernel (file path, data area, and so on).

Based on the classification of the I/O model by UNIX programming, UNIX provides 5 I/O models, namely:

(1) Blocking I/O model: The most commonly used is the blocking I/O model, under the default conditions all file operations are blocked!!

(2) Non-blocking I/O model

(3) I/O multiplexing model

(4) Signal-driven I/O model

(5) asynchronous I/O model


For most programmers, there is no need to know the bottom-level details of network programming, and all we need is a concept that, for the operating system, the underlying

is to support asynchronous I/O communication, Java NiO Core class library multiplexer is based on epoll multiplexing technology implementation!!


During I/O programming, multi-threaded or I/O multiplexing techniques can be used to process multiple client access requests. / o

Multiplexing allows multiple I/O blocking to be multiplexed to the same select block, allowing the system to handle more than one single thread

Client requests. Compared with the traditional multi-threaded/multi-process model, the greatest advantage of I/O multiplexing is that the system overhead is small and the system does not need to create

New additional processes or threads, and do not need to maintain the operation of these threads and processes, reducing the maintenance workload of the system and saving system resources

, the main application scenarios for I/O multiplexing:

(1) The server needs to handle multiple sockets in the listening state or multiple connection states;

(2) The server needs to handle multiple network protocol sockets


Linux currently supports I/O multiplexing system calls with SELECT, Pselect, poll, Epoll



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Netty Learning (i) a brief introduction to the network IO model under--linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.