What exactly does SO_REUSEADDR do?

Answer Posted / chaitanya

This socket option tells the kernel that even if this port is busy (in the TIME_WAIT state), go ahead and reuse it anyway. If it is busy, but with another state, you will still get an address already in use error. It is useful if your server has been shut down, and then restarted right away while sockets are still active on its port. You should be aware that if any unexpected data comes in, it may confuse your server, but while this is possible, it is not likely.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is a socket a file?

480


What is af_inet in socket?

478


What is difference between socket and websocket?

489


Whats the difference between select() and poll()?

1214


Where is the socket located?

478






What is the difference between a socket and a port?

467


How can I force a socket to send the data in its buffer?

1099


How can I set the timeout for the connect() system call?

1114


How many sockets can a cpu have?

501


What is difference between socket () and serversocket () class?

495


How can I tell when a socket is closed on the other end?

975


How do I use TCP_NODELAY?

1111


Why sockets are used?

525


Is there any advantage to handling the signal, rather than just ignoring it and checking for the EPIPE error? Are there any useful parameters passed to the signal catching function?

1041


Are unix sockets faster than tcp?

496