简体   繁体   English

内部套接字接收缓冲区的实现

[英]Internal socket receive buffer implementation

I'm working on an embedded application, where i receive some sensor values over UDP. 我正在开发一个嵌入式应用程序,该应用程序通过UDP接收一些传感器值。 The board I'm using runs the 2.4 kernel on an ARM processor. 我使用的电路板运行在ARM处理器上的2.4内核。 The problem is the following: once my internal socket buffer is full only the newest value gets replaced. 问题如下:一旦我的内部套接字缓冲区已满,就只能替换最新的值。 So the internal buffer is not implemented as a circular buffer, which it should be, as i found out studying some articles. 因此,我在研究某些文章时发现,内部缓冲区并未实现为循环缓冲区,而应该将其实现为。 Can i somehow change the behaviour of the internal receive buffer? 我可以以某种方式更改内部接收缓冲区的行为吗?

I already found out that there is no way to "flush" that buffer from the application side. 我已经发现,没有办法从应用程序端“刷新”该缓冲区。 The best idea I've got is checking whether the receive buffer is full, before receiving any packets and if so fist read out all the old packets manually. 我已经得到了最好的办法是检查接收缓冲区是否已满,接收到任何数据包之前,如果是手动的拳头读出所有的旧包。 Is there any better approach? 有没有更好的办法?

I hope it's somehow clear what I mean, any help is appreciated. 希望我能清楚地理解我的意思,感谢您的帮助。

The best idea I've got is checking whether the receive buffer is full, before receiving any packets and if so fist read out all the old packets manually. 我已经得到了最好的办法是检查接收缓冲区是否已满,接收到任何数据包之前,如果是手动的拳头读出所有的旧包。

I'd not bother checking whether the receive buffer is full, rather always read all packets until no more are there and use the last received, which contains the newest value. 我不会费心检查接收缓冲区是否已满,而是总是读取所有数据包,直到没有更多数据包为止,并使用最后接收的数据包(其中包含最新的值)。

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

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