Day45 - Learning Log¶
📌 Summary¶
Implemented a TCP server using:
- blocking socket
- poll
- epoll
- non-blocking I/O
📌 Key Learnings¶
1. poll vs epoll¶
- poll scans all fds
- epoll only returns ready fds
2. epoll is NOT non-blocking¶
- epoll = event notification
- non-blocking = fd behavior
3. accept must drain queue¶
Otherwise connections may be missed.
4. recv() behavior¶
n > 0→ datan == 0→ client closedn < 0→ error
5. EAGAIN is not an error¶
Used to terminate read loop.
6. send() is not guaranteed to send all¶
- partial write possible
- may return EAGAIN
7. Non-blocking design¶
- never block inside event loop
- always return control to loop
8. TX queue design insight¶
TX queue is:
NOT:
9. EPOLLOUT must be controlled¶
Wrong:
Correct:
📌 Observations¶
- epoll handles burst connections efficiently
- connection lifecycle becomes clear with logs
- testing tools (nc) behavior affects results
📌 Next Improvements¶
- TX queue + EPOLLOUT
- integrate input subsystem (Day44)
- support protocol parsing