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 | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
socketfromfd-0.2.0.tar.gz
(15.4 kB
view hashes)
Built Distribution
Close
Hashes for socketfromfd-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c2737ad21168f0e9bc92ac0094aaffef8bbf04aae709d0fbcf1dabf9f020f72 |
|
MD5 | 4c1ad1c7945d920e4e324904ea737679 |
|
BLAKE2b-256 | f20a5aad7c524ec46348587ecd919247a011b60ebdb8f0fd89c45778d8b642b6 |