How youngyangyang04/muduo-core works
muduo-core is a C++ TCP networking library for event-driven servers. A server application configures and starts TcpServer; its acceptor accepts clients, connections are assigned to event loops, and callbacks deliver received data to the application. Responses use connection buffers and are written when the socket is ready. The implementation separates server/connection handling, the Reactor event-dispatch machinery, and low-level networking and support utilities. Relationships are based on the excerpts, SOURCE INDEX references, and README; some detailed wiring is documented rather than shown in sampled implementation excerpts.
Main entry points: TcpConnection.cc TCP connection · TcpServer.cc TCP server · EventLoop.cc Event loop · Channel.cc Event channel
Components 19
Server connections
- TCP server
src/TcpServer.cc - Connection acceptor
src/Acceptor.cc - TCP connection
src/TcpConnection.cc - I/O buffers
src/Buffer.cc
Reactor dispatch
- Event loop
src/EventLoop.cc - Event channel
src/Channel.cc - Poller interface
src/Poller.cc - epoll poller
src/EPollPoller.cc - Poller selection
src/DefaultPoller.cc - Loop thread pool
src/EventLoopThreadPool.cc - Loop thread
src/EventLoopThread.cc
Network primitives
- Socket wrapper
src/Socket.cc - Internet address
src/InetAddress.cc
Runtime support
- Thread wrapper
src/Thread.cc - Thread identity
src/CurrentThread.cc - Logging
src/Logger.cc - Timestamps
src/Timestamp.cc
Other components
- Server application
- TCP clients
Connections 30
- Server application → TCP server: configures and starts
README.md - TCP server → Connection acceptor: sets up listener
README.md - Connection acceptor → TCP server: reports accepted clients
README.md - TCP server → Loop thread pool: selects loop threads
README.md - Loop thread pool → Loop thread: creates loop threads
src/EventLoopThreadPool.cc - Loop thread → Event loop: runs loop
src/EventLoopThread.cc - TCP server → TCP connection: creates connections
README.md - TCP connection → Event channel: registers callbacks
src/TcpConnection.cc - TCP connection → Event loop: schedules I/O work
src/TcpConnection.cc - TCP connection → Socket wrapper: writes and shuts down
src/TcpConnection.cc - TCP connection → I/O buffers: reads and buffers data
src/TcpConnection.cc - TCP connection → Server application: delivers message callbacks
src/TcpConnection.cc - TCP clients → Connection acceptor: connects to listener
- Event channel → Event loop: updates registration
src/Channel.cc - Event loop → Poller interface: polls active channels
src/EventLoop.cc - Event loop → Event channel: dispatches ready events
src/EventLoop.cc - Poller interface → Event channel: tracks channels
src/Poller.cc - Poller selection → epoll poller: selects implementation
src/DefaultPoller.cc - epoll poller → Event channel: returns ready channels
src/EPollPoller.cc - TCP server → Internet address: uses listen address
- Connection acceptor → Socket wrapper: accepts connections
- Socket wrapper → Internet address: uses socket addresses
src/Socket.cc - Thread wrapper → Thread identity: records thread identity
src/Thread.cc - Event loop → Thread identity: checks loop thread
- TCP server → Logging: logs server events
src/TcpServer.cc - TCP connection → Logging: logs connection events
src/TcpConnection.cc - Event loop → Timestamps: records poll time
- Event channel → Timestamps: timestamps read events
- epoll poller → Timestamps: returns poll time
- Logging → Timestamps: formats log time
src/Logger.cc