UDP 数据包在套接字上停留多长时间? [英] How long does a UDP packet stay at a socket?

查看:45
本文介绍了UDP 数据包在套接字上停留多长时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果数据已发送到客户端,但客户端正忙于执行其他操作,那么使用 recvfrom() 可以读取多长时间的数据?

If data is sent to the client but the client is busy executing something else, how long will the data be available to read using recvfrom()?

此外,如果在读取第一个数据包之前发送第二个数据包,会发生什么情况,第一个数据包丢失,而下一个数据包坐在那里等待读取?

Also, what happens if a second packet is sent before the first one is read, is the first one lost and the next one sitting there wating to be read?

(windows - udp)

(windows - udp)

推荐答案

通常,数据会被缓冲直到被读取.我想如果您等待的时间足够长以至于驱动程序完全耗尽空间,它就必须做一些事情,但是假设您的代码正常工作到一半,那应该不是问题.

Normally, the data will be buffered until it's read. I suppose if you wait long enough that the driver completely runs out of space, it'll have to do something, but assuming your code works halfway reasonably, that shouldn't be a problem.

典型的网络驱动程序将能够缓冲大量数据包而不会丢失任何数据包.

A typical network driver will be able to buffer a number of packets without losing any.

这篇关于UDP 数据包在套接字上停留多长时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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