This guide is for learning. Run these commands only on your own lab or servers.
Sockets are how programs send data over a network. This example runs on one computer using the loopback address, so it stays inside your own machine.
server.py
import socket
s = socket.socket()
s.bind(("127.0.0.1", 5000))
s.listen(1)
conn, addr = s.accept()
data = conn.recv(1024)
conn.sendall(data.upper())
conn.close()client.py
import socket
c = socket.socket()
c.connect(("127.0.0.1", 5000))
c.sendall(b"hello lab")
print(c.recv(1024))
c.close()Start the server in one terminal, then run the client in another. You should see HELLO LAB come back.
Keep servers bound to 127.0.0.1 while you learn, so nothing outside your computer can connect.
Want the full guide? Networking Fundamentals with Python · $9.99View on Gumroad



