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.1.0.tar.gz
(15.4 kB
view details)
Built Distribution
File details
Details for the file socketfromfd-0.1.0.tar.gz
.
File metadata
- Download URL: socketfromfd-0.1.0.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1db0a00c6ec6c34f8b5ad814e699f73263c352024256d56ae4da1a1696486a21 |
|
MD5 | 7286ae761d0ab9e3249c08e22c2b945d |
|
BLAKE2b-256 | dfe5b28dc68d960fffcc7d1317655b1f6cd470246cf88fa0319b02b8441663ca |
File details
Details for the file socketfromfd-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: socketfromfd-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8695d96b21b33f03281ed7e329657912fd2ff01ea288000f7519b57fbe2818fc |
|
MD5 | 6f8765008d826a5f5d25a31479f58cb1 |
|
BLAKE2b-256 | 3deef30652c23e45fe8e11cac209ee2913dfbb2348c277196abeefc8a3ebd098 |