简体   繁体   中英

is it a good idea to reuse port using option SO_REUSEADDR which is already in TIME_WAIT state?

I know there are already lot of questions on SO_REUSEADDR. Still I could not get its disdvantages and have few questions.

1]what is the danger associated with SO_REUSEADDR when we are not using any linger option.

2]Will there be any packet loss scenario?

3]What happens if i get something on the port which in time wait state?

4]What will happen to that packet which was received in TIME_WAIT?

and last but very important

5]Is there any performance impact of having lot many ports in TIME_WAIT state at any point of time?

The disadvantage is that you might receive data that was intended for an earlier connection and not related to the new connection, corrupting that communication session. The whole point of TIME_WAIT is to allow the OS to flush out lingering data. If a packet is received for a IP/Port in TIME_WAIT state, the packet is discarded. By using SO_REUSEADDR , you bypass that safety catch.

If you have a lot of ports in TIME_WAIT state, you can cause port exhaustion, which prevents new connections from being established until ports in TIME_WAIT clear up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM