Sadra is a Python back-end developer who loves the architectural design behind the software. A GitHub Campus Expert and open-source contributor. He spends his free time writing high-quality technical articles.
Frequently Asked Questions
What is socket programming in Python?
Socket programming is the act of making connections through the network ports between the nodes. In Python, you use the socket standard library to establish the connections and use them.
How do we send messages continuously?
Consider the example in the guide. All you need to do is keep the connection open and consider each side as two clients when working with recv() and send() through a loop.
Can I keep a socket connection open?
In this article’s scenario, you brought a one-time connection example whereas the nodes were sending only one message before the termination. You can control each connection’s longevity by setting intervals and timeouts, but you need to make sure to close it once you’re done.
Is it possible to have private chat rooms?
Yes. On a smaller scale, you can consider each port as a socket connection and manage them concurrently.
What is a descriptor leak?
It’s a state where the system file allocation is out of control. In most cases, garbage collector is smart enough to manage the leak’s causes, such as unallocated and unneeded resource usage.
Can I keep track of the transmitted messages/data?
You can use any additional library during your connection and message transmission. You can track all logs and messages as well as data sent and received by interacting with a database, such as SQLite.