sahildua2305 / py-socketchat

A simple chat application using sockets programming written in Python
2 stars 0 forks source link

When do the server raise an exception? #1

Open freezed opened 6 years ago

freezed commented 6 years ago

Hi, I'm new in python and I am discovering networking with socket and select. I am auditing your code and I wonder in which situation the try/except bloc (lines: 40-49, in chat_server.py) could raise an exception.

Thanks -- freezed

sahildua2305 commented 6 years ago

Hi @freezed, that's a 4 years old piece of code. Honestly, I don't remember exactly. What I can tell from reading the code is that if client connection drops in between and we try to receive data from that socket connection, it will throw an exception. Hence, we catch that exception and remove that client from our list of existing connections.

Let me know if this clears your doubt.

freezed commented 6 years ago

Hu hu, no problems! I put this block in my code but I did not find the case when server listen a client disconnecting… so I used a keyword to tell it. Sockets & Select seems to be nice tools, but I need practice more to understand correctly how they work. Thanks and feel free to close this issue.