__del__ pattern?

Tom Anderson twic at urchin.earth.li
Tue Aug 16 07:42:23 EDT 2005


On Mon, 15 Aug 2005, Peter Hansen wrote:

> Tom Anderson wrote:
>
>> Only one socket can be bound to a given port at any time, so the second 
>> instance of SpecialClass will get an exception from the bind call, and 
>> will be stillborn. This is a bit of a crufty hack, though - you end up 
>> with an open port on your machine for no good reason. If
>
> If you bind with self.sock.bind(('localhost', 4242)) instead, at least 
> you don't have much of a security risk since the port won't be available 
> for connections from outside the same machine.

Excellent suggestion, thanks!

> Using '' instead of 'localhost' means bind to *all* interfaces, not just 
> the loopback one.

Doesn't '' mean 'bind to the *default* interface'?

tom

-- 
All we need now is a little energon and a lotta luck



More information about the Python-list mailing list