For example, it seems that there are not many answers found on the Internet. Isn’t reasoning a process recognized by a port number? The ip and port of the server should also be fixed.
In addition, like node.js, every time a new connection comes, it is an event. how do you identify which event belongs to a client?
Since BSD Socket, the network port is a file for application programmers. The operating system is also very similar to a file in management. The operating permissions of the file are shared by parent-child processes
fork()Had that socket before, then
fork()Later subprocesses can also use the same port.
The new connection does not have the problem you mentioned. It should be how the existing connection sends data to determine which connection the data is from. This bottom layer is implemented by IP protocol. The operating system can also reverse the data packets from that connection. nodejs uses asynchronous method, and this is implemented by the operation provided by operating system such as epoll. The operating system will tell nodejs which connection the new data comes from, and then nodejs will process it again.