As I embark on my cybersecurity journey, I’ve decided to document everything I learn. You can check out my previous blog here.
Today, I started working on a home firewall in Python to learn about sockets, networking, and how programs interact with the OSI model. I began by exploring Python’s socket module to create a basic client-server communication system.
✅ How to create and bind a socket to a port
✅ How to listen for incoming connections
✅ Handling concurrent connections using socket.listen()
✅ Sending and receiving data between client and server
✅ Understanding raw sockets and how they work
✅ Debugging network issues using netstat
While running multiple tests, I encountered an issue where my server wouldn’t restart😅. Turns out, the port was already in use due to previous runs 😁. I learned to use netstat to find and kill processes blocking my port.😎
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("0.0.0.0", 8080))
sock.listen(5)
conn, client_IP = sock.accept()
conn.send("Hello, this is the server".encode("utf-8"))
conn.close()
sock = socket.socket()
sock.connect(("SERVER_IP", 8080))
data = sock.recv(2048) print(data.decode("utf-8"))
sock.close()
This might not seem like a big achievement, but for me, it’s a step closer to my dream: becoming a Security Engineer. Every small step matters!
Here is a little reference if you want to:
Soon i will upload my progress on github for cleaner documentation.
Looking forward to continuing this journey—see you in the next blog! 🚀
Happy Programming, Happy Hacking🧑💻
Published on: Sat Mar 01 2025