1.ipv4 structure
2.socket
3.connect
4.bind
bind is to bind the ip and port to the socket. The
client may not call bind to bind the port. The kernel will temporarily allocate one, but the server cannot bind the port. If it is not bound Then the client cannot connect to the server.
5. After
listening
6. accept 7. close
fork, the descriptor opened by the parent process is copied to the child process, so the reference count of these file descriptors is 2. Only the parent and child processes are Close the descriptor, the descriptor will be actually closed
8. After the descriptor reference count
fork, the parent and child processes must all close the connected socket, otherwise the socket is not really closed, the descriptor will be exhausted, and the tcp connection will not be terminated