[Python-Dev] socket module recvmsg/sendmsg

Guido van Rossum guido at python.org
Mon May 1 16:54:55 CEST 2006

Is there a question or a request in here somewhere? If not, c.l.py.ann
would be more appropriate.

If you want that code integrated into core Python, read python.org/dev
and prepare a patch for SF!


On 4/30/06, Heiko Wundram <me+python-dev at modelnine.org> wrote:
> Hi all!
> I've implemented recvmsg and sendmsg for the socket module in my private
> Python tree for communication between two forked processes, which are
> essentially wrappers for proper handling of SCM_RIGHTS and SCM_CREDENTIALS
> Unix-Domain-Socket messages (which are the two types of messages that are
> defined on Linux).
> The main reason I need these two primitives is that I require (more or less
> transparent) file/socket descriptor exchange between two forked processes,
> where one process accepts a socket, and delegates processing of the socket
> connection to another process of a set of processes; this is much like a
> ForkingTCPServer, but with the Handler-process prestarted.
> As connection to the Unix-Domain-Socket is openly available, the receiving
> process needs to check the identity of the first process; this is done using
> a getsockopt(SO_PEERCRED) call, which is also handled more specifically by my
> socket extension to return a socket._ucred-type structure, which wraps the
> pid/uid/gid-structure returned by the corresponding getsockopt call, and also
> the socket message (SCM_CREDENTIALS) which passes or sets this information
> for the remote process.
> I'd love to see these two socket message primitives (of which the first,
> SCM_RIGHTS, is available on pretty much any Unix derivative) included in a
> Python distribution at some point in time, and as I've not got the time to
> push for an inclusion in the tree (and even less time to work on other Python
> patches myself) at the moment, I thought that I might just post here so that
> someone interested might pick up the work I've done so far and check the
> implementation for bugs, and at some stage these two functions might actually
> find their way into the Python core.
> Anyway, my private Python tree (which has some other patches which aren't of
> general interest, I'd think) is available at:
> http://dev.modelnine.org/hg/python
> and I can, if anyone is interested, post a current diff of socketmodule.*
> against 2.4.3 to the Python bug tracker at sourceforge. I did that some time
> ago (about half a year) when socket-passing code wasn't completely
> functioning yet, but at least at that point there didn't seem much interest
> in the patch. The patch should apply pretty cleanly against the current HEAD
> too, at least it did the last time I checked.
> I'll add a small testsuite for both functions to my tree some time tomorrow.
> --- Heiko.
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list