SO_REUSEPORT on linux

后端 未结 5 1872
有刺的猬
有刺的猬 2021-02-05 13:28

I want to know if SO_REUSEPORT option is enabled in LINUX 2.6 or not ??

If I try to use it and compile my code I get following error

01.c:72: error: `SO_         


        
5条回答
  •  滥情空心
    2021-02-05 13:49

    It was added during the 3.9 cycle in a series of patches by Tom Herbert, as you can see here, in order to better support multithreaded web servers.

    The patch itself can be found here if you want to integrate SO_REUSEPORT into an older kernel version.

    And yes, you can use SO_REUSEPORT to bind a socket to the same address and port as another connection, as long as the initial connection also uses SO_REUSEPORT (and any other connections sharing the source address and port). This is done to prevent port hijacking by rogue applications.

提交回复
热议问题