【发布时间】:2012-03-30 13:37:46
【问题描述】:
我只想在 UDP 数据包中发送一个短值,但运行命令
echo -n "hello" | nc -4u localhost 8000
我可以看到服务器正在获取 hello 内容,但我必须按 Ctrl+c 退出 netcat 命令。
发送hello后如何让它退出?
对不起,因为噪音,我重新阅读了手册页并找到了-q 选项。
echo -n "hello" | nc -4u -q1 localhost 8000
有效(1 秒后退出)。
由于某种原因,它不适用于-q0。
【问题讨论】:
-
debian 手册页:
-q seconds: after EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever.