fdsend is yet another file descriptor passing abstraction, specifically for Python. This package offers a few conveniences not commonly found together in other abstractions: sending multiple files at once, sending arbitrary data, and working with both files and file descriptors.
fdsend is free software, licensed under the GPL.
Python >= 2.2 is required, as is SCM_RIGHTS support on AF_UNIX sockets. Only Linux has been tested.
The current version is fdsend-0.1 (03 Nov 2004)
import fdsend import socket # for socket.error # -- sender; send 12 files # nulldevs = [ file('/dev/null') for i in xrange(12) ] fdsend.sendfds(sock, "here you go!", fds = nulldevs) # -- recipient; receive up to 128-byte message, and up to 32 files # (msg, fds) = fdsend.recvfds(sock, 128, numfds = 32) import os fds = [ os.fdopen(fileno) for fileno in fds ] # -- exception handling # import socket try: notasock = file("/dev/null") fdsend.sendfds(notasock, "This won't work!") except socket.error, e: import errno if e == errno.ENOTSOCK: print "What did you expect? :)"
Report problems, bugs, feature requests, successes to me at firstname.lastname@example.org.