有什么方法可以使用 Netcat 和 UDP 发送文件(图片或视频)。它默认为 TCP,但我想使用 UDP 发送。我尝试简单地将 -u 添加到 nc 命令,但这不起作用。这是我正在使用的两个命令:
cat File.jpg | nc -u -l 777
nc -u 192.168.x.x 777 | pv -b > newfile.jpg
Run Code Online (Sandbox Code Playgroud)
我将我的 IP 地址用于 xx,以及我 PC 上的相应文件。我也在使用 Ubuntu。
感谢您的任何帮助!
像这样尝试:
nc -u -l 7777 > newfile.jpg #on the destination machine
cat file.jpg | nc -u 192.168.x.x 7777 #on the source machine
Run Code Online (Sandbox Code Playgroud)
通常,您希望获取文件的机器“侦听”(先运行),并在侦听时通过 udp 发送数据。UDP 没有“握手”序列,即使没有人在侦听,也会立即发送数据包*。
*有时您会收到一个 ICMP 数据包,该端口已关闭(无法访问),但您不能依赖它(防火墙等)