简体   繁体   English

udp套接字中接收缓冲区/队列的最大大小

[英]Maximum size of Receive Buffer/Queue in udp socket

I have developed a udp server/client application in which server has one socket at which it continuously receives data from 40 clients. 我开发了一个udp服务器/客户端应用程序,其中服务器有一个套接字,它连续从40个客户端接收数据。 Now I want to know that what happens if all of the 40 Clients send data at a time? 现在我想知道如果所有40个客户端一次发送数据会发生什么? According to my understanding, data must be queued in receive buffer and next time when I call recvfrom() the data queued in the buffer is received ie I shall have to call recvfrom() 40 times to receive data of all the 40 Clients even if all the Clients sent data simultaneously. 根据我的理解,数据必须在接收缓冲区中排队,下次当我调用recvfrom()时,接收到缓冲区中排队的数据,即我必须调用recvfrom()40次才能接收所有40个客户端的数据,即使所有客户端同时发送数据。 Also, I want to know that all of the data of 40 Clients will be queued in receive buffer or some of the data will be discarded too? 另外,我想知道40个客户端的所有数据都将在接收缓冲区中排队,或者某些数据也将被丢弃? Also, what is the maximum buffer size in which data can be queued in receive buffer and after what limit is data dropped? 另外,数据可以在接收缓冲区中排队的最大缓冲区大小是多少,在数据丢失的限制之后是多少?

I shall have to call recvfrom() 40 times to receive data of all the 40 Clients even if all the Clients sent data simultaneously. 我将不得不调用recvfrom()40次来接收所有40个客户端的数据,即使所有客户端同时发送数据也是如此。

In other words, you're asking whether separate UDP datagrams can be combined by the network stack. 换句话说,您要问的是网络堆栈是否可以组合单独的UDP数据报。 The answer is: no, they'll arrive as separate datagrams requiring separate calls to recvfrom() . 答案是:不,它们将作为单独的数据报到达,需要单独调用recvfrom()

Also, I want to know that all of the data of 40 Clients will be queued in receive buffer or some of the data will be discarded too? 另外,我想知道40个客户端的所有数据都将在接收缓冲区中排队,或者某些数据也将被丢弃?

UDP does not guarantee delivery. UDP不保证交付。 Packets can be dropped anywhere along the route: by the sending host, by any devices along the route and by the receiving host. 数据包可以沿路径的任何位置丢弃:发送主机,路由上的任何设备和接收主机。

Also, what is the maximum buffer size in which data can be queued in receive buffer and after what limit is data dropped? 另外,数据可以在接收缓冲区中排队的最大缓冲区大小是多少,在数据丢失的限制之后是多少?

This is OS-dependent and is usually configurable. 这取决于操作系统,通常是可配置的。 Bear in mind that packets might get dropped before even reaching the receiving host. 请记住,数据包可能会在到达接收主机之前丢失。

Indeed it all depends on the size of your OS socket buffers. 实际上,这完全取决于OS套接字缓冲区的大小。 In linux its fairly easy to configure, so all you probably need to do it to google how to change it for your Windows system. 在linux中它很容易配置,所以你可能需要谷歌如何为你的Windows系统更改它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM