getting socket.bind() exception, but no actual error
Michael Fuhr
mfuhr at fuhr.org
Wed Nov 3 04:30:21 EST 2004
clarence at silcom.com (Clarence Gardner) writes:
> mfuhr at fuhr.org (Michael Fuhr) wrote in message news:<4187d4fc$1_4 at omega.dimensional.com>...
> ? Because you get "Address already in use" exceptions due
> > to old connections still being in the TIME_WAIT state? If so, are
> > you aware that server processes should usually set the SO_REUSEADDR
> > socket option before calling bind()? Or is there some other reason
> > that bind() fails?
>
> No, that's the only issue. I thought using that option was frowned upon,
> but it's also been a couple of years since I needed to think about such
> things, and I was too lazy to look it up for now.
SO_REUSEADDR is hardly frowned upon -- quite the contrary: it's
recommended. See for example the socket bible, _UNIX Network
Programming_, Vol 1, by W. Richard Stevens. On p 207 (2nd edition),
in the summary for the Socket Options chapter, Stevens says:
The most commonly used options that we might encounter are
SO_KEEPALIVE, SO_RCVBUF, SO_SNDBUF, and SO_REUSEADDR. The
latter should always be set for a TCP server before it calls
bind.
Earlier in the chapter, on pp 194-197, Stevens discusses SO_REUSEADDR
in detail and says that "_All_ TCP servers should specify this
socket option to allow the server to be restarted in this situation"
(emphasis his; page numbers may differ in the 3rd edition).
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
More information about the Python-list
mailing list