简体   繁体   English

Winsock的IO和消息解析重叠

[英]Winsock overlapped IO and message parsing

I have to implement a (client) socket which requires high throughput (> 800Mbps) and low latency running on Windows 7 server. 我必须实现一个(客户端)套接字,该套接字需要在Windows 7服务器上运行的高吞吐量(> 800Mbps)和低延迟。 Overlapped IO seems the way to go for high performance. 重叠的IO似乎是追求高性能的方法。

Read some documentation on the subject, as far as I can see the advantage of overlapped I/O is that you pass some structures with buffer to the OS and you are notified when they are filled. 阅读有关该主题的一些文档,据我所知,重叠的I / O的优点是您将一些带有缓冲区的结构传递给OS,并在它们被填充时得到通知。

No I am wondering what the common ways are to combine this with a packet based protocol (length delimited packets, header contains size of datablock) Of course I can just read arbitrary chunks of data and copy the required number of bytes into a message struture. 不,我不知道将这种方法与基于数据包的协议(长度分隔的数据包,标头包含数据块的大小)相结合的常用方法是什么,当然我可以读取任意数据块并将所需数量的字节复制到消息结构中。 This means an additional copy action. 这意味着要执行其他复制操作。

Second option might be passing the message structure as a buffer with the header size, after getting it back pass the same structure again to read the requested number of databytes. 第二种选择可能是将消息结构作为标头大小的缓冲区传递,将其返回后,再次传递相同的结构以读取请求的数据字节数。 In this case the first chunk read is small, but the data is saved into the message structure, and while the data block read is pending the read of the next header block can be initialized. 在这种情况下,读取的第一个块很小,但是数据被保存到消息结构中,并且在读取数据块的过程中,可以初始化下一个标头块的读取。

Any experiences or ideas how to handle length delimited packets the most efficient ? 任何经验或想法如何最有效地处理定界数据包?

Thanks, 谢谢,

如果您知道数据包的大小,请查看分散/聚集I / O。

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

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