linux环境下如何使用udp传输文件

发布于 2024-10-21 20:57:52 字数 121 浏览 2 评论 0原文

你好,谁能告诉我如何编写代码使用 udp 传输协议将文件从一台 Linux 电脑发送到另一台 Linux 电脑?我有将字符串从一台电脑传输到另一台电脑的代码,我想知道如何传输文件。如果有人帮助我,我将不胜感激 非常感谢你提前..

hi can any one tell me how to write code to send files from one linux pc to another linux pc using udp transfer protocol? i had the code for transfering strings from one pc to another pc i want to know how to transfer files . i would be thankful if anyone helps me
thank you so much in advance..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画中仙 2024-10-28 20:57:52

这是一个不平凡且毫无意义的练习,因为要有效地完成它,您最终会重新发明 TCP。

要获得“简单”的方法,请尝试实施 TFTP。 TFTP 是一个非常愚蠢的协议,其中每个帧都被单独确认,发送者在发送下一帧之前等待响应。这不是进行文件传输的好方法,并且比 TCP 差得多。

我认为 TFTP 被设计为以最少量的代码实现(而不是高效)。它历来被网络引导加载程序使用,有时必须存在于一个小 ROM 中(历史限制)。

根据网络的延迟和带宽,确认单个帧并在发送下一帧之前等待确认,将导致性能非常差(除非您的网络具有极低的延迟低带宽,通常不会齐头并进)。

This is a nontrivial, and also pointless exercise, as to do it efficiently, you end up reinventing TCP.

For an "easy" way of doing it, try implementing TFTP. TFTP is a very stupid protocol where each frame is individually acknowledged and the sender waits for the response before sending the next frame. This is not a good way of doing file transfer and is much worse than TCP.

TFTP I think was designed to be implemented in the minimum amount of code (rather than being efficient). It has historically been used by network boot loaders, which must sometimes live in a tiny rom (a historical limitation).

Depending on the latency and bandwidth of your network, ack'ing individual frames and waiting for the ack before sending the next one, will result in very poor performance (unless your network has extremely low latency and low bandwidth, which do not generally go hand-in-hand).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文