开发者

Why not using SO_REUSEADDR on Unix TCP/IP servers?

开发者 https://www.devze.com 2023-03-26 09:38 出处:网络
I have not seen any important TCP/IP server not use SO_REUSEADDR : Apache HTTP Server SO_REUSEADDR usage

I have not seen any important TCP/IP server not use SO_REUSEADDR :

  • Apache HTTP Server SO_REUSEADDR usage
  • nginx SO_REUSEADDR usage
  • Very Secure FTPD SO_REUSEADDR usage
  • exim SO_REUSEADDR usage
  • Postfix SO_REUSEADDR usage
  • OpenSSH SO_REUSEADDR usage

Is there any use case for not using SO_REUSEADDR on TCP/IP servers ?

I mean, would making the OS always use SO_REUSEADDR break any server that does not use it?

Do you know a TCP/IP server that not uses SO_REUSEADDR for a reason?

(of course you may not want to use it on MSWindow开发者_StackOverflows as it allows to run two servers on the same port)


Well, UNP (Stevens 2004) says:

SO_REUSEADDR allows a listening server to start and bind its well-known port, even if previously established connections exist that use this port as their local port.

All TCP servers should specify this socket option to allow the server to be restarted


Of course there is a very valid reason for not using SO_REUSEADDR by default.

It would allow ANY process to bind to the same listening socket as a sensitive Internet service and accept connections on its behalf! That permits unlimited eavesdropping and man-in-the-middling.

0

精彩评论

暂无评论...
验证码 换一张
取 消