TCP/IP, UDP and Sockets
TCP gives reliable ordered streams; UDP sends fast, unreliable datagrams; sockets are the programming interface to both.
Easy
import socket
with socket.create_connection(("example.com", 80), timeout=5) as s:
s.sendall(b"HEAD / HTTP/1.0\r\nHost: example.com\r\n\r\n")
print(s.recv(200))
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.