Linux – Netcat UDP transfer never stop until terminated via CTRL+C

linuxlinux-networkingnetcat

I'm trying to send data across machine using Netcat using UDP instead of TCP.

Now, unlike TCP(Netcat over TCP) which used to mark the completion of the file transfer by exiting the nc process, the UDP(Netcat over UDP) process never seem to exit, unless done forcefully using CTRL+C

Example

$ pv upd_mnl_client.rb | nc -u 192.168.1.117 5555

385 B 0:00:00 [39.8kiB/s] [==================================================================>] 100%
^C ## I have to do this because the process never exit

Any Clue what I'm missing above.

Best Answer

You didn't specify --send-only, so it has no way to know whether or not you're done receiving. If you want it to receive data too, then you'll have to tell it when you're done. If you don't want it to receive data, specify --send-only.