- Podcasts
- CyberSecurity Summary
- Python Network Programming Cookbook
About this episodeA practical guide for developing real-world networking applications and DevOps automation scripts. The material covers fundamental…
You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary
Get the Book now from Amazon:
https://www.amazon.com/Python-Network-Programming-Cookbook-Faruque-ebook/dp/B00JAAW11M?&linkCode=ll2&tag=cvthunderx-20&linkId=bfc241ccac9916546d176acf02712eb1&language=en_US&gaOptInStatus=true&ref_=as_li_ss_tl
Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Python Network Programming Cookbook
It's like a forced override. Another fundamental property you can manipulate is blocking behavior, using set blocking. Because by default, sockets are blocking, right? Yes. If your Python script tells a socket to receive data and no data is there yet, your entire program just freezes. It waits indefinitely.
A non-blocking socket inside a poorly written loop will consume 100% of your CPU. It just endlessly pulls an empty connection, generating massive amounts of heat and starving other processes. Wow. And this specific problem, how to efficiently manage connections without spinning the CPU out of control, that is the exact barrier you have to cross to scale an application.
That's a great way to visualize it. The select function takes lists of sockets, ones you want to read from, ones you want to write to, and ones to monitor for errors. And it asks the operating system, hey, which of these hundreds of sockets actually have network data ready to be processed right now?
So you learn the low-level mechanics so you can debug the high-level frameworks when they inevitably behave unexpectedly. Exactly. We have a highly optimized server that won't crash under pressure, but a server is useless if it can't speak the right languages. We need to move up the OSI model away from the raw transport layer of TCP sockets and into the application layer where the rest of the internet actually lives.
There are highly practical reasons for it. The first is automated testing. If you're building a responsive web app, the server might serve different CSS files depending on whether it thinks the user is on Chrome, Safari, or an iPhone. You have to spoof those user agents in your Python test scripts to verify the server is routing the formatting correctly.
Okay, so we've built this incredible automated infrastructure. We have web requests flowing, APIs talking, and Fabric dynamically configuring fleets of servers. But how do we actually monitor this for security vulnerabilities? How do we audit what is actually traveling across our copper wires?
It's a very valid concern. But in the realm of cybersecurity, ignorance is never a defense. Yes, these are the mechanical primitives of offensive attacks. But think about it. If you do not intimately understand exactly how a TCP sequence number can be predicted by an attacker or how a spoofed ICMP packet can map the logic of your firewall rules, you cannot possibly engineer an intrusion detection system capable of catching those attacks.
Think back to the custom port scanner we just discussed, which loops through network ports one by one, waiting for a connection timeout or a refusal. If you were tasked with engineering that scanner to be non-blocking, so it could scan a thousand ports simultaneously instead of one by one, which multiplexing technique from earlier would you choose and why?
