Stealing from here I have set up a small Python script which listens on a port and prints out all of the UDP packets it receives:
import socket
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((UDP_IP, UDP_PORT))
while True:
data, addr = sock.recvfrom(1024)
print "received message:", repr(data)
Now I am using netcat
to send data to this script. Here is my command line.
echo -e "foo:1|c" | netcat -v -u localhost 5005
And here is the output from Python:
received message: 'X'
received message: 'X'
received message: 'X'
received message: 'X'
received message: 'X'
received message: 'foo:1|c\n'
These first four or so "X" lines arrive at roughly one-second intervals, then the final two lines arrive roughly simultaneously.
My question is this: where are these extra "X" packets coming from, and if the source is netcat
, then how can I prevent netcat
from emitting them? This is BSD's netcat
, I believe.
-v
"give[s] more verbose output". Do you think this could be a defect innetcat
? – Megmega