使用 UDP 的 Netcat 流式传输
我可以让 netcat 使用 TCP 流式传输视频
{server} cat [movie].avi | nc [client ip address] 65535
{client} nc -l -p 65535 | mplayer -
我尝试使用 -u 命令通过 UDP 发送,但这不起作用
{server} cat [movie].avi | nc -u [client ip address] 65535
{client} nc -u -l -p 65535 | mplayer -
有什么想法吗?
I can get netcat to stream a video using TCP
{server} cat [movie].avi | nc [client ip address] 65535
{client} nc -l -p 65535 | mplayer -
i have tried using the -u command to send via UDP but this doesn't work
{server} cat [movie].avi | nc -u [client ip address] 65535
{client} nc -u -l -p 65535 | mplayer -
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TCP 和 UDP 的字节流之间存在根本区别...
TCP 结果是您的 TCP 示例有效,但 UDP 示例无效,因为 mplayer 永远不知道何时处理它所获取的字节。
解决此问题的一种方法是双方超时...首先启动客户端并定时完成(将 nc 部分置于子 shell 中,这样它就不会阻塞):
接下来启动服务器...在这种情况下,我展示了将文件推送到 udp/65535 上的 192.168.12.238
最后,请确保选择的超时时间足够长,以便对 shell 命令进行排序并完成网络传输(这通常相当快,如果您位于有线以太网 LAN 上)。
There is a fundamental difference between streaming bytes with TCP and UDP...
The consequences are that your TCP example works, but the UDP example doesn't because mplayer never knows when to process the bytes it is getting.
One way to solve this is with a timeout on both sides... First start your client with a timed finish (backgrounding the nc portion in a subshell so it won't block):
Next start your server... in this case, I show it pushing the file to 192.168.12.238 on udp/65535
Finally, be sure you choose the timeout to be long enough to sequence the shell commands and finish the network transfer (which is normally rather quick, if you're on a wired ethernet LAN).