Giter VIP home page Giter VIP logo

debian-python-fdsend's Introduction

fdsend README

Introduction
------------
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.

License
-------
fdsend is free software, licensed under the GPLv2+.  It was originally developed
by Michael J. Pomraning (http://pilcrow.madison.wi.us/) and is currently
maintained by Philipp Kern and Fabian Knittel.  Small portions of fdsend are
adapted from other sources, see the main source file for details.

Requirements
------------
Python >= 2.2 is required, as is SCM_RIGHTS support on AF_UNIX sockets. Only
Linux has been tested.  For setup.py setuptools is needed.

Installation
------------
  $ tar zxf fdsend-$VERSION.tar.gz
  $ cd fdsend-$VERSION
  $ python setup.py build
  $ python setup.py install

Details
-------
fdsend allows the passing of open files between unrelated processes via
local sockets (using SCM_RIGHTS), a process known as file descriptor
passing.  The following functions are available:

  sendfds()
  recvfds()
  socketpair()

Unlike some other simplifications of the sendmsg()/recvmsg() interface,
fdsend allows multiple files to be transferred in a single operation, and
permits ordinary socket messages to accompany the files.  Additionally,
fdsend understands bona fide Python sockets and files, as well as objects
implementing fileno() methods and integers representing file descriptors.

Errors are raised via the socket.error exception object.

Example
-------

  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[0] == errno.ENOTSOCK:
          print "What did you expect? :)"

Known Bugs
----------
No provision is made to support msg_accrights systems (nor I_SENDFD fd
passing).

Feedback
--------
Please report problems, bugs, feature requests, successes on the mailing
list <[email protected]>.

Misc
----
- The usual limitation in "rights" send/recv fd implementations, wherein
  msg_iov conveys a single, often hardcoded, byte, is a venerable approach
  dating back at least as far as Stevens' APUE examples (1992).  For many
  applications, it's no limitation at all.
- socketpair() is only for Python versions lacking this under the 'socket'
  module.

Related Interest
----------------
- scgi: (python) contains a passfd module.
  (http://www.mems-exchange.org/software/scgi/)
- sendmsg: The sendmsg module (python) is a mostly complete sendmsg interface.
  (http://www.python.org/pycon/dc2004/papers/51/migration-code/sendmsg/)
- Socket::MsgHdr: (perl) offers a full sendmsg interface.
  (http://search.cpan.org/dist/Socket-MsgHdr/lib/Socket/MsgHdr.pm)
- bglibs:  provides a variety of UNIX-ish conveniences, including a
  socket_sendfd function.
  (http://untroubled.org/bglibs/)
- I_SENDFD ioctl: The I_SENDFD ioctl is an alternative approach for
  streams-based systems
  (http://pubs.opengroup.org/onlinepubs/007908799/xsh/ioctl.html)

debian-python-fdsend's People

Contributors

fknittel avatar pkern avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.