Registry / http-networking / PySocks

PySocks

JSON →
library1.7.1pypypi✓ verified 79d ago

PySocks is a core SOCKS client module that provides a socket wrapper supporting SOCKS4, SOCKS5, and HTTP proxy tunneling. The current version is 1.7.1. Releases are infrequent and focus on maintenance.

pip install PySocks
INSTALL
IMPORT
SIG · PYSOCKS
P
PySocks
http-networkingpythonv1.7.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

socks
import socks
import socks; socks.setdefaultproxy(socks.SOCKS5, 'host', port)

Demonstrates monkey-patching socket to route all traffic through a SOCKS5 proxy.

import socks import socket socks.setdefaultproxy(socks.SOCKS5, 'localhost', 9050) socket.socket = socks.socksocket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('httpbin.org', 80)) s.sendall(b'GET /ip HTTP/1.1\r\nHost: httpbin.org\r\n\r\n') print(s.recv(4096).decode()) s.close()
Debug
Known issues
gotchaMonkey-patching socket.socket affects entire Python process; avoid in production or use per-connection approach.
fix
Use socks.socksocket directly for individual sockets instead of setting socket.socket
affects: all
deprecatedThe original 'socks' package on PyPI (version 0) is a stub that does nothing; use 'PySocks' instead.
fix
pip install PySocks and import socks; uninstall the stub package: pip uninstall socks
affects: any
gotchaPySocks does not support authentication for SOCKS4; only SOCKS5 supports username/password.
fix
Use SOCKS5 proxy type if authentication is needed.
affects: all
Upgrade
Version history
1.7.1latest on PyPI · released Sep 20, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
88 hits · last 30 days
node
78
OpenAI (training)
1
Resources
PySocks — pip install PySocks · libregistry