我怎么知道我的数据包成功到达指定的UDP? [英] How do I know my packets are successfully reached the specified UDP?

查看:92
本文介绍了我怎么知道我的数据包成功到达指定的UDP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将字节数组发送到udp端口,但我不知道如何确认。



我尝试过:



我试图将数据包发送到UDP服务器。我在接收器中收到相同的数据包。这意味着数据包是否成功发送?

I am sending bytes array into udp port but I dont know how to ack.

What I have tried:

I have tried to send packets to UDP server. I am receiving the same packets in the receiver. Is that mean packets are successfully sent?

推荐答案

UDP是无状态协议 - 维基百科 [ ^ ]你没有任何反馈。



如果您需要某种确认,则必须在顶级协议中实施。这意味着您必须定义此类协议或使用现有协议并在代码中实现它。但在这种情况下通常最好使用TCP而不是UDP来避免实现大多数有状态功能。



UDP is a Stateless protocol - Wikipedia[^] where you don't have any feedback.

If you need some kind of acknowledgement, it has to be implemented in the top protocol. That means you have to define such a protocol or use an existing one and implement it in code. But it is usually better to use TCP instead of UDP in such cases to avoid implementing most of the stateful features.

引用:

我试图将数据包发送到UDP服务器。我在接收器中收到相同的数据包。这意味着数据包是否成功发送?

I have tried to send packets to UDP server. I am receiving the same packets in the receiver. Is that mean packets are successfully sent?

目前尚不清楚你的意思。如果服务器只是将收到的数据包回送给客户端,则它是某种验证/确认。但不是一个可靠的。可靠的验证要求发送者正在维护可以识别分组的发送分组列表。这也适用于初始接收者现在是发送者的确认分组。它甚至变得更加复杂,因为不保证按顺序接收数据包。



如果你考虑所有这些以及如何实现它,你会发现有一个现有的协议已经执行此操作:TCP。

It is not clear what you mean here. If the server is just echoing back the received packets to the client, it is some kind of verification / acknowledgement. But not a reliable one. A reliable verification requires that senders are maintaining a list of send packets where the packets can be identified. This applies also to the acknowledgement packets where the initial receiver is now a sender. It even gets more complicated because it is not guranteed that packets are received in order.

If you think about all this and how to implement it, you will find out that there is an existing protocol that does this already: TCP.


简单,你不要!



UDP不保证传送数据包,更不用说接收器以正确的顺序获取数据包了。



UDP通常用作广播协议,将数据发送到一个或更多客户,其中数据不必完整,以便接收者理解它,即视频流。
Simple, YOU DON'T!

UDP does not guarantee delivery of packets, let alone the receiver(s) getting the packets in the correct order.

UDP is typically used as a "broadcast" protocol, sending data to one or more clients where the data doesn't have to be complete for the receivers to understand it, i.e. video streaming.


这篇关于我怎么知道我的数据包成功到达指定的UDP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆