SO_REUSEPORT (since Linux 3.9) Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address. This option must be set on each socket (including the first socket) prior to calling bind(2) on the socket. To prevent port hijacking, all of the processes binding to the same address must have the same effective UID. This option can be employed with both TCP and UDP sockets. For TCP sockets, this option allows accept(2) load distribution in a multi-threaded server to be improved by using a distinct listener socket for each thread. This provides improved load distri‐ bution as compared to traditional techniques such using a single accept(2)ing thread that distrib‐ utes connections, or having multiple threads that compete to accept(2) from the same socket. For UDP sockets, the use of this option can provide better distribution of incoming datagrams to multiple processes (or threads) as compared to the traditional technique of having multiple pro‐ cesses compete to receive datagrams on the same socket.
SO_REUSEPORT (since Linux 3.9) 内核3.9 Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address. 允许多个IP或者IPv6的socket绑定到同一个socket地址。 This option must be set on each socket (including the first socket) prior to calling bind(2) on the socket. 该选项必须在调用bind之前设置到每个socket上(包括第一个socket)。 To prevent port hijacking, all of the processes binding to the same address must have the same effective UID. 为了防止劫持,绑定到同一地址的所有进程要有相同的EUID。 This option can be employed with both TCP and UDP sockets. TCP和UDP socket都可以使用该选项。For TCP sockets, this option allows accept(2) load distribution in a multi-threaded server to be improved by using a distinct listener socket for each thread. 对TCP socket,该选项可以改善多线程服务器中的accept负载分发,通过给每一个线程一个不同的监听socket。 This provides improved load distribution as compared to traditional techniques such using a single accept(2)ing thread that distributes connections, or having multiple threads that compete to accept(2) from the same socket. 比起传统的做法,比如用单一的线程来分发连接,或者在多线程中accept相同的socket来竞争,该选项可以改善负载分发。 For UDP sockets, the use of this option can provide better distribution of incoming datagrams to multiple processes (or threads) as compared to the traditional technique of having multiple pro‐ cesses compete to receive datagrams on the same socket. 对UDP socket,使用该选项可以提供更好的多进程/线程中的数据包分发;传统的做法是多进程在同一个socket上竞争接受数据包。
SO_REUSEPORT (since Linux 3.9)
Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address. This
option must be set on each socket (including the first socket) prior to calling bind(2) on the
socket. To prevent port hijacking, all of the processes binding to the same address must have the
same effective UID. This option can be employed with both TCP and UDP sockets. For TCP sockets, this option allows accept(2) load distribution in a multi-threaded server to be
improved by using a distinct listener socket for each thread. This provides improved load distri‐
bution as compared to traditional techniques such using a single accept(2)ing thread that distrib‐
utes connections, or having multiple threads that compete to accept(2) from the same socket. For UDP sockets, the use of this option can provide better distribution of incoming datagrams to
multiple processes (or threads) as compared to the traditional technique of having multiple pro‐
cesses compete to receive datagrams on the same socket.
Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address.
允许多个IP或者IPv6的socket绑定到同一个socket地址。
This option must be set on each socket (including the first socket) prior to calling bind(2) on the socket.
该选项必须在调用bind之前设置到每个socket上(包括第一个socket)。
To prevent port hijacking, all of the processes binding to the same address must have the same effective UID.
为了防止劫持,绑定到同一地址的所有进程要有相同的EUID。
This option can be employed with both TCP and UDP sockets.
TCP和UDP socket都可以使用该选项。For TCP sockets, this option allows accept(2) load distribution in a multi-threaded server to be improved by using a distinct listener socket for each thread.
对TCP socket,该选项可以改善多线程服务器中的accept负载分发,通过给每一个线程一个不同的监听socket。
This provides improved load distribution as compared to traditional techniques such using a single accept(2)ing thread that distributes connections, or having multiple threads that compete to accept(2) from the same socket.
比起传统的做法,比如用单一的线程来分发连接,或者在多线程中accept相同的socket来竞争,该选项可以改善负载分发。 For UDP sockets, the use of this option can provide better distribution of incoming datagrams to
multiple processes (or threads) as compared to the traditional technique of having multiple pro‐
cesses compete to receive datagrams on the same socket.
对UDP socket,使用该选项可以提供更好的多进程/线程中的数据包分发;传统的做法是多进程在同一个socket上竞争接受数据包。