Why not using SO_REUSEADDR on Unix TCP/IP servers?

2020-07-10 10:43发布

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

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 MSWindows as it allows to run two servers on the same port)

2条回答
虎瘦雄心在
2楼-- · 2020-07-10 11:09

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.

查看更多
我命由我不由天
3楼-- · 2020-07-10 11:23

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

查看更多
登录 后发表回答