使用 boost::asio::async_write 时数据混乱

发布于 2024-10-08 09:42:28 字数 92 浏览 0 评论 0原文

当我使用 boost::asio::async_write 发送一些大数据时,我发现收到的数据很乱,但总大小是正确的。两组数据似乎有重叠。我该怎么做才能避免这种情况发生?

when I was using boost::asio::async_write to send some large data, I found the data I received was messed up, but total size was correct. it seemed like two groups of data overlapped. What can I do to avoid this happen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔梦 2024-10-15 09:42:28

如果没有代码,那就是在黑暗中刺伤。

  1. 检查您是否没有使用相同的缓冲区进行读/写操作
  2. 如果您使用 async_xxx 操作,请确保它们不重叠,即您绝不能调用 async_read 直到上一次读取完成,async_write 也是如此
  3. 您没有将数据正确复制到缓冲区中
  4. 您遇到了网络问题
  5. 来自太空的辐射正在随机修改线路上的位..

谁知道...

Without code, it's a stab in the dark..

  1. Check that you are not using the same buffer for read/write operations
  2. If you are using async_xxx operations, ensure that they are not overlapped, i.e. you must never call async_read until the previous read completes and same for async_write
  3. You don't copy the data into the buffers correctly
  4. You've got a network issue
  5. Radiation from space is randomly modifying bits on the wire..

who knows...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文