socket
Stdlib — NetworkingPython 2.0+Advanced
Low-level TCP/UDP socket interface
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
- Dependencies
- None — Python Standard Library
- Install
Included with Python
Learn by Difficulty
Quick Example
python
import socket print(f"Hostname: {socket.gethostname()}") print("Socket types:", [s for s in dir(socket) if s.startswith("SOCK_")][:4])
The socket module is part of Python's standard library. Low-level TCP/UDP socket interface.
Try in PlaygroundTags
stdlibnetworkingtcpudplow-level
Related Items
ssl
Stdlib — Networking
TLS/SSL wrapper for sockets; enables HTTPS
asyncio
Stdlib — Concurrency
Async I/O: event loop, coroutines, tasks, streams, queues
http.client
Stdlib — Networking
Low-level HTTP protocol client
selectors
Stdlib — Concurrency
High-level I/O multiplexing (select/poll/epoll/kqueue)
socketserver
Stdlib — Networking
Framework for building network servers