<aside> 💻
L3.3 — Network Programming (Python) by Kirk Martinez. This lecture covers how to do network programming using Python's socket library — creating TCP and UDP sockets, the client-server echo pattern, address families (AF_INET vs AF_INET6), socket types (SOCK_STREAM vs SOCK_DGRAM), binding to interfaces/ports, DNS lookups with gethostbyname(), error handling for network code, the high-level HTTP requests library, WebSockets for persistent bidirectional connections (with asyncio), and Remote Procedure Calls (XML-RPC) for calling functions on remote machines.
</aside>
AF_INET (IPv4) and AF_INET6 (IPv6)SOCK_STREAM (TCP), SOCK_DGRAM (UDP), SOCK_RAW (ICMP etc.)socket.socket() with no arguments creates a default IPv4 TCP socketb'Hello'), not strings'' (empty string) listens on all interfaces (Wi-Fi + Ethernet)socket.gethostbyname() to resolve a hostname to an IP address via DNSSOCK_DGRAM, sendto(), and recvfrom()try/except blocks to handle socket.error — especially important for UDP (expect packet loss)requests library for high-level HTTP: requests.get(), .post(), .put(), .delete()requests handles TCP, DNS, and even HTTPS (TLS) automatically