Can somebody give me an advice about what to learn?

Hans Mulder hansmu at xs4all.nl
Wed Oct 3 13:55:44 EDT 2012


On 1/10/12 00:14:29, Roy Smith wrote:
> In article <mailman.1677.1349019431.27098.python-list at python.org>,
>  Chris Angelico <rosuav at gmail.com> wrote:
> 
>> you can't, for instance, retain a "socket connection object" across 
>> that sort of reload.
> 
> Yeah, that's a problem.  There's nothing fundamental about a TCP 
> connection endpoint which precludes it being serialized and passed 
> around.  The amount of state involved is pretty small.  Unless I've 
> forgotten something, 2 IP addresses, 2 port numbers, a few bits worth of 
> TCP protocol state, and, for open connections, 2 sequence numbers.  
> Maybe a couple of timers, but I don't think they're strictly necessary.  
> The problem is, most of that state is private to the kernel.

You're looking at the wrong abstraction level.  A socket connection
object is a thin wrapper around a file descriptor.  Most posix platforms
allow you to pass file descriptors to other processes running on the
same box.  Thus, most posix platforms *do* allow you to pass socket
connection objects around, though you won't win prizes for portability.

> On the other hand, you could do what "screen" does, and spawn a process 
> per connection to hold the connection open :-)

That won't work for the sort of application we're discussing, because
it creates too many processes.  A pool of processes, each handling
many connections, might work though.

-- HansM



More information about the Python-list mailing list