Socket, TCP, and etc
TCP
Keepalive
https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/
Socket in general
The first newbie question when doing socket programming is how to tell a socket has received all bytes from the other party. If you do not handle it well, you may get stuck forever at recv. The python Socket Programming HOWTO summarizes this issue as the fundamental truth of sockets:
messages must either be fixed length (yuck), or be delimited (shrug), or indicate how long they are (much better), or end by shutting down the connection
There are only 4 ways! Joash Xu illustrates the first three in his blog. For the last option, you can read Ivan Velichko’s blog. Also, I want to mention that HTTP protocol uses both delimited method and length method. It uses \r\n to separate the title line and header lines. Then it uses content-length header to determine the size of data section.
Netlink socket
The best tutorial online is from Kevin He.
Side note: Kevin He built a company call Deepmotion. It sounds interesting.
Epoll
TOD: read this https://gist.github.com/dtoma/564375673b354397efc5 This is almost the same implementation as Java’s default http server implementation