Metadata-Version: 2.0
Name: socketfromfd
Version: 0.1.0
Summary: socket.fromfd() with auto-detection of family and type
Home-page: https://github.com/tiran/socketfromfd
Author: Christian Heimes
Author-email: christian@python.org
License: Apache License, Version 2.0
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: System :: Networking
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: test
Requires-Dist: coverage; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Provides-Extra: test_docs
Requires-Dist: docutils; extra == 'test_docs'
Requires-Dist: markdown; extra == 'test_docs'
Provides-Extra: test_pep8
Requires-Dist: flake8; extra == 'test_pep8'
Requires-Dist: pep8-naming; extra == 'test_pep8'

socketfromfd -- Create a socket from a file descriptor
======================================================

socketfromfd is an enhanced version of
`socket.fromfd() <https://docs.python.org/3/library/socket.html#socket.fromfd>`__
from Python's standard library. It uses ctypes and libc's
`getsockopt() <http://linux.die.net/man/2/getsockopt>`__ function to
auto-detect the file descriptor's socket family, type and protocol.

.. code:: python

    >>> import socket
    >>> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    >>> sock
    <socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('0.0.0.0', 0)>

    >>> from socketfromfd import fromfd
    >>> newsock = fromfd(sock.fileno())
    >>> newsock
    <socket.socket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 0)>


