He, I have a server python script that listens on ip address ” and port 1337 and now I am trying to connect on the client side to that socket. But for some reason I cannot do that. If i will change the binding address to “127.0.0.1” it will work just fine, but I have been told to use this
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
Windows host can’t receive UDP packets from WSL-2 guest
I’m trying to have a simple UDP echo client/server communicate with each other. The client program (which runs in the host Windows) sends packets to the server (which runs in WSL-2), and the server receives them, but the server’s reply is never reaches the client. The output on Windows: The output on Linux: And now I’m stumped. TCP connections work
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
Understanding how python sockets are used to send large number of bytes
I am trying to send an image via python sockets. I wrote a simple program for doing that. server.py client.py Now this is the problem. In my case, when I run python server.py test.jpg, the length of list(fh) is 374. And those parts from list(fh) are sent one at a time via socket. But when I recieve them from client.py,
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
sending pickled data via UDP, unpickle fails with UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xff in position 0: ordinal not in range(128)
This is my code snippet that sends data over ethernet from one PC to another which is working fine. At the receiver end, I am not able to decode it. It says: This is the snippet at the receiver end Answer Why are you even pickling the data? You can send binary data via UDP anyway: Then at the receiving
Python Socket – Sniffer does not intercept all packets
My sniffer is running on linux via virtualbox. A network bridge with promiscuous mode between linux and windows. I want to intercept windows packets while on linux. But my program does not intercept these packets. However, it can do this if I run tcpdump and the program itself at the same time. I created the socket as follows: Answer Add