How to send only one UDP packet with netcat?

后端 未结 5 1953
挽巷
挽巷 2021-01-29 19:20

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 serve

5条回答
  •  [愿得一人]
    2021-01-29 20:16

    On a current netcat (v0.7.1) you have a -c switch:

    -c, --close                close connection on EOF from stdin
    

    Hence,

    echo "hi" | nc -cu localhost 8000
    

    should do the trick.

提交回复
热议问题