workerman icon indicating copy to clipboard operation
workerman copied to clipboard

SO_REUSEPORT option. How a child process gets its own listening socket?

Open ghost opened this issue 1 year ago • 1 comments

Hi!) I have a similar question, discussed here: https://github.com/walkor/Workerman/issues/156

I would like to understand how child process get it own listening socket. Master creates several listening sockets and then fork, after this each of workers inherits several sockets, and should close (decrease ref counter) all except one socket, and accept new connection from it? As a result all workers have independent queue for receiving request to connection?

ghost avatar Dec 23 '22 16:12 ghost

When SO_REUSEPORT is true master will not create listening sockets, but each children process will create it's own listening socket.

walkor avatar Dec 25 '22 03:12 walkor