nc (netcat) hangs, waiting for more data, in UDP mode.
Solution 1:
I ended up fixing the problem by switching to socat
:
while read line; do
printf "folder.counter:value|1c" | socat -t 0 - UDP:$host:$port
done
Solution 2:
You can specify 0 as a timeout value to -w, so it won't wait at all.
Solution 3:
adding -v option solved my issue. The reason I am not sure.
Solution 4:
I had same issue; solved it using the -c
option:
-c, --close close connection on EOF from stdin
so something like
while read line; do
printf "folder.counter:value|1c" | nc -cu $host $port
done
Yeah, does not really make sense to "close" a udp-connection - but that ended up working.