How to reuse TCP listening socket immediately after it was connected at least once?

Roy Smith roy at panix.com
Mon May 25 07:27:37 EDT 2009


In article <gvd1id$8jj$2 at lust.ihug.co.nz>,
 Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> wrote:

> In message <roy-3C4DED.09214724052009 at news.panix.com>, Roy Smith wrote:
> 
> > In article <gvb8fn$7gm$1 at lust.ihug.co.nz>,
> >  Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> wrote:
> > 
> >> The right thing to do is try to ensure that all your connections are
> >> properly closed at shutdown. That may not be enough (if your server
> >> crashes due to bugs), so the other thing you need to do is retry the
> >> socket open, say, at 30-second intervals, until it succeeds.
> > 
> > That may be a reasonable thing to do for production code, but when you're
> > building and debugging a server, it's a real pain to not be able to
> > restart it quickly whenever you want (or need) to.
> 
> On the contrary, I run exactly the same logic--and that includes socket-
> handling logic--in both test and production servers. How else can I be sure 
> it'll work properly in production?

If running without SO_REUASEADDR works for you, that's great.  I was just 
pointing out how it can be useful in cases such as the OP's, where he's 
getting bind errors when he restarts his server.



More information about the Python-list mailing list