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

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Wed May 27 01:55:38 EDT 2009


In message <roy-50FE2E.07273725052009 at news.panix.com>, Roy Smith wrote:

> 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?
> 
> 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.

And I was pointing out how important it was to make sure your code deals 
gracefully with those errors.




More information about the Python-list mailing list