5 ms·
Using socket option SO_REUSEPORT allows multiple processes to bind to same port.
by ctrlrsf 5y ago
Using socket option SO_REUSEPORT allows multiple processes to bind to same port.
- VWWHFSfQ 5y agois this what it's actually doing though? It doesn't say the reuseport option to the listen directive is required for this.
- riyadparvez 5y agoIs there any restrictions on this option? Eg only children of the same parent process are allowed to bind to same port. Otherwise how does the packet distribution work? And how does the response from that port work?
- garaetjjte 5y ago>So long as the first server sets this option before binding its socket, then any number of other servers can also bind to the same port if they also set the option beforehand. [...] To prevent unwanted processes from hijacking a port that has already been bound by a server using SO_REUSEPORT, all of the servers that later bind to that port must have an effective user ID that matches the effective user ID used to perform the first bind on the socket. https://lwn.net/Articles/542629/ https://lwn.net/Articles/542629/