Difference between sending data via UDP in Bash and with a Python script
- by Kevin Burke
I'm on a Centos box, trying to send a UDP packet to port 8125 on localhost. When I run this Python script:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto('blah', ("127.0.0.1", 8125))
The data appears where it should on port 8125. However when I send the data like this:
echo "blah" | nc -4u -w1 127.0.0.1 8125
Or like this:
echo "blah" > /dev/udp/127.0.0.1/8125
The data does not appear in the backend. I know this is horribly vague but it's UDP and it's hard to determine why one packet is being sent and the other is not. Do you have any ideas about how to debug this issue further? I'm on a Centos machine.