Skip to content

Tag: sockets

Python non-blocking socket

Hi I am trying to create a very simple peer-to-peer chatting program in python. The first user can runs the server.py program below to bind to a socket. Then another user can use netcat to connect to the server and communicate. However, the program is only able to get the user’s input and send to the ot…

Why does this function block?

I have some code that is reading data (if there is any) from a non-blocking socket and printing it, but somehow when this happens (data is received & printed) the function then blocks and does not return unless I kill the sending process (which also uses a non-blocking stream to send the data). Obviously …

Connection reset by peer error showing despite using try

I have a server like this: but the error of ConnectionResetError: [Errno 104] Connection reset by peer still occurs on client disconnection, shouldn’t the error be handled by try except ? If not how else do I handle this error without the script being terminated? Answer From this answer I found the foll…