12. Networking¶
Hardware control connected the camera to a wire and a known partner on the other end. Networking is what happens when the partner is not on that wire – a laptop on the same Wi-Fi, a sensor in another room, a server in another country – and when the path between the two endpoints passes through hardware nobody on either side controls.
Two modules cover Python’s side of this. The
network module brings the camera onto a network
in the first place: joining a Wi-Fi network or plugging
into Ethernet, picking up an address, getting the cam
ready to participate. The socket module is what
Python code opens to actually send and receive bytes
once the link is up. The pages ahead walk through what
sits between, layer by layer, so “open a socket and
write bytes” feels inevitable instead of magic.
The bottom layers
The network layer
The transport layer
Sockets in Python
Security
Wrap up