Skip to content
Advertisement

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 other side. The user

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 I have done something wrong but

Send in-memory bytes (file) over multipart/form-data POST request. Python

;TLDR I want to send a file with requests.send() using multipart/form-data request without storing the file on a hard drive. Basically, I’m looking for an alternative for open() function for bytes object Hello, I’m currently trying to send multipart/form-data request and pass in-memory files in it, but I can’t figure out how to do that. My app receives images from

Python client socket can’t receive data from a successful response

Socket can’t receive any data from the server, when there is a successful response, but with bad requests it can. Also server responds, just the socket can’t receive data (checked in WireShark) Answer First, the HTTP GET expects a sequence of CR LF characters after each header line not just a single ‘n’ character and an extra CR LF after

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 following solution: but I recommend reading the comment

Advertisement