Difference between sending data via UDP in Bash and with a Python script

Posted by Kevin Burke on Server Fault See other posts from Server Fault or by Kevin Burke
Published on 2012-12-12T04:06:56Z Indexed on 2012/12/12 5:05 UTC
Read the original article Hit count: 294

Filed under:
|
|
|
|

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.

© Server Fault or respective owner

Related posts about bash

Related posts about python