boost::asio 和 send() 的使用

发布于 2024-11-29 09:49:20 字数 326 浏览 1 评论 0原文

使用 boost::asio::ip::tcp:socket 时,可以使用多种方法来写入/发送数据。还有 asio::write 将套接字作为参数等。我的问题是,在使用标准 send() 函数时,boost asio 库是否存在任何兼容性问题(陷阱)?

是否应该绝对不要在 boost::asio::ip::tcp:socket 上使用标准 send() 函数?或者也许它工作得很好,但是当你在 boost::asio 库中已经拥有了这方面可能需要的一切时,为什么还要使用 send() 呢?

When using a boost::asio::ip::tcp:socket there are many methods one can use to write/send data. There's also asio::write that takes the socket as a parameter, etc. My question is is there any compatibility issues (gotchas) with the boost asio libraries when using the standard send() function?

Should one categorically never use the standard send() function on a boost::asio::ip::tcp:socket? Or maybe it works fine, but why use send() when you already have everything you could possibly need in this regard within the boost::asio libraries.

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

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

发布评论

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

评论(1

り繁华旳梦境 2024-12-06 09:49:20

对于UDP套接字,您需要使用boost asio send和send_to函数,而write方法用于同步流写入,即用于TCP,不能用于UDP,因为它是“流写入”。

You need to use the boost asio send and send_to function for UDP sockets while the write method is used for synchronous stream write i.e used for TCP and cannot be used for UDP as it is "stream write".

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