Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

socket.fromfd() with auto-detection of family and type

Project description

socketfromfd is an enhanced version of socket.fromfd() from Python’s standard library. It uses ctypes and libc’s getsockopt() function to auto-detect the file descriptor’s socket family, type and protocol.

>>> 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)>

Project details


Release history Release notifications

This version
History Node

0.2.0

History Node

0.1.0

History Node

0.1.dev1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
socketfromfd-0.2.0-py2.py3-none-any.whl (4.2 kB) Copy SHA256 hash SHA256 Wheel 2.7 Jan 21, 2017
socketfromfd-0.2.0.tar.gz (15.4 kB) Copy SHA256 hash SHA256 Source None Jan 21, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page