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

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Mon May 25 04:59:24 CEST 2009


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?




More information about the Python-list mailing list