Skip to main content

simplysocket

simplysocket is a small helper for creating Python standard-library sockets using familiar family and protocol names. It has no runtime dependencies.

Installation

python -m pip install simplysocket

Usage

from simplysocket import socket

tcp_socket = socket.defaultSocket()
udp_socket = socket.createSocket(socketType="UDP")
ipv6_socket = socket.createSocket(socketFamily="ipv6")

for sock in (tcp_socket, udp_socket, ipv6_socket):
    sock.close()

addresses = socket.getAddrInfo("localhost", 443, type=socket.TCP)
ip_address = socket.getIP("https://example.com")
service_name = socket.getService(443, "tcp")
open_ports = socket.scanHost(
    "example.com",
    workers=5,
    retService=True,
    startPort=1,
    endPort=1024,
    proc=[True, 2],
)

createSocket supports the families v4, ipv4, inet, ip4, v6, ipv6, inet6, ip6, and bluetooth; and the types TCP, UDP, and RAW. Omitting the family or type selects IPv4 or TCP, respectively. Unsupported family or type names raise ValueError. Bluetooth raises NotImplementedError on platforms where Python does not expose Bluetooth sockets. Creating raw sockets may require elevated operating-system permissions. socket.getAddrInfo (also available as socket.getaddrinfo) forwards to Python's standard-library resolver and accepts the same host, port, family, type, proto, and flags arguments. socket.getIP accepts a hostname or URL and resolves its IPv4 address. socket.getService looks up a port's service name, optionally for a protocol, and returns "unknown" when no service mapping exists. socket.scanHost scans an inclusive port range for open IPv4 TCP ports. It defaults to ports 1–9999 and uses two processes by default, with the requested number of worker threads in each process. The proc argument is a two-item list, [use_processes, process_count]; set it to [False, 2] to disable processes and use only worker threads. Each connection attempt is limited to 0.2 seconds, and open ports are returned as formatted entries. Set retService=False to omit service names. Only scan systems you own or are authorized to assess. On spawn-based platforms such as Windows, call process-enabled scans from code protected by an if __name__ == "__main__": guard.

Development

Build and validate the distribution with:

python -m pip install --upgrade build twine
python -m unittest discover -s tests
python -m build
python -m twine check dist/*

Upload only after reviewing the built artifacts and confirming the project name and release metadata:

python -m twine upload dist/*

License

Distributed under the MIT License. See LICENSE.

Metadata

Release files for simplysocket 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simplysocket 0.1.6
File Size Uploaded
simplysocket-0.1.6.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simplysocket 0.1.6
File Interpreter ABI Platform
simplysocket-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / simplysocket-0.1.6.tar.gz

Download URL simplysocket-0.1.6.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
65e935465375a442fbad17782c7e1a208d59fcdfa0ca86eaa5e4ff4b7b64e460
BLAKE2b-256 checksum
How to use checksums
8031f835168ae6ca4baaed75155cd19e2e8f5cb18fed52c55418abeccf8eadf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / simplysocket-0.1.6-py3-none-any.whl

Download URL simplysocket-0.1.6-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e9bbc73605692afb0dfa149955442a906eff06813741a082854f56bca5844ca
BLAKE2b-256 checksum
How to use checksums
1b023b2c983e3c194cd20b51227f91b53da6b18870629f816a4258e832c1e7d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page