Skip to content
UPEEC

socket

Low-level network connections over TCP and UDP.

Intermediate
Comments 0
import socket
with socket.create_connection(("example.com", 80), timeout=5) as s:
    s.sendall(b"GET / HTTP/1.0\r\nHost: example.com\r\n\r\n")
    print(s.recv(1024))

UDP: socket.socket(socket.AF_INET, socket.SOCK_DGRAM) — common for sensor broadcasts.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.