I want to send only one short value in a UDP packet, but running the command
echo -n "hello" | nc -4u localhost 8000
I can see that the server is getting the hello stuff but I have to press Ctrl+c to quit the netcat command.
How can I make it quit after sending hello?
Sorry, for the noise, I re-read the man page and found the -q
option.
echo -n "hello" | nc -4u -q1 localhost 8000
works (it quits after 1 second).
For some reason it does not work with -q0
.
-q seconds: after EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever.
– Pooley