Introduction
The first two articles mainly introduce the epoll and socket encapsulation of redis. This article will introduce in detail the specific implementation of redis network communication. Simply put, redis's network communication mainly implements the main process and implementation of server listening client connection and processing.
Source code
Networking. c
Analysis
Network Communication Process
Description
The main principle of redis network communication is similar to the general asynchronous network programming framework. It uses the socket on the server to listen to the incoming connection, create the socket corresponding to the connection, and then read and listen to the socket, after that, the event loop processor will listen to specific read events, parse and obtain the returned data, and then listen to the corresponding write events. When the socket is writable, reply will be returned to the client.
Remarks
The network framework is lightweight. In this lightweight network framework, redis will describe the Connection Client's parsing and subsequent processing in the following articles.