An evolutionary engineering roadmap of custom application-layer network protocols, low-level socket architecture, and stream framing engines built from scratch in Python.
This repository serves as a progressive laboratory tracking the journey from raw Operating System network primitives up to full-featured custom application protocols.
Stage 1 establishes the structural virtual "pipe" between two completely isolated processes using the computer's kernel network stack.
socket.AF_INET: Instructs the OS to utilize the IPv4 addressing family framework.socket.SOCK_STREAM: Configures the socket connection type to TCP. This guarantees in-order, error-checked delivery of a continuous stream of bytes.- Kernel Buffering: Demonstrates the handoff between Python's application memory space and the Operating System's low-level Send/Receive RAM buffers.
To verify the local network interface handshake, you must run the processes across two distinct terminal instances.
The server binds to the local loopback interface and enters a blocking state, waiting for incoming synchronization flags.
python stage_1_handshake/my_server.pyIn a second terminal window, execute the client script to trigger the hardware-level handshake.
python stage_1_handshake/my_client.pyServer Terminal: Will print "Socket successfully bound...", halt at listen(), and unblock, displaying "Handshake accepted" the moment the client runs.
Client Terminal: Will log "Attempting to connect..." followed immediately by a clean termination output confirming "Client successfully connected."
The TCP Stream Reality: Discovered that TCP does not transfer data in neat, separated "boxes" or individual application messages. It treats data as a continuous, endless stream of bytes.
The Application Layer Mandate: Verified that while the OS kernel guarantees packet delivery and sequence ordering, it has no understanding of payload context. Defining text boundaries (framing) must be handled explicitly by application code in the stages ahead.