passing a socket to a spawned process.

Alex Martelli aleaxit at
Wed Oct 13 09:48:57 CEST 2004

Marcos Dione <mdione at> wrote:

> On Mon, Oct 11, 2004 at 10:23:27AM -0700, Mike M wrote:
> > Is it possible?  In the parent process, I have a socket that binds,
> > listens and then accepts new connections (which creates new sockets in
> > the process).  I want to be able to pass some of these new sockets to
> > a spawned process.  Is it possible, and if so how?
>   just accept() before fork()'ing. the socket will be cloned. then close the
> socket on the parent, unless needed.

Unfortunately I believe that's platform-dependent.  Specifically: your
suggestion should work on any sensible operating system... BUT a tad
over 50% of Python programs are estimated to run on Windows, and, on
THAT platform, I know your idea can't work (no fork!) and I don't know
how to answer the OP's question (except by suggesting he move, if
feasible, to any sensible platform -- any BUT Wind0ws...!-).


More information about the Python-list mailing list