简体   繁体   English

boost::asio 和 send() 的使用

[英]boost::asio and use of send()

When using a boost::asio::ip::tcp:socket there are many methods one can use to write/send data.当使用boost::asio::ip::tcp:socket时,可以使用多种方法来写入/发送数据。 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?还有将套接字作为参数的 asio::write 等。我的问题是,在使用标准send() function 时,boost asio 库是否存在任何兼容性问题(陷阱)?

Should one categorically never use the standard send() function on a boost::asio::ip::tcp:socket ?应该断然永远不要在boost::asio::ip::tcp:socket上使用标准send() function 吗? 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.或者它工作得很好,但是当你在 boost::asio 库中已经拥有了这方面可能需要的一切时,为什么还要使用send()

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 ie used for TCP and cannot be used for UDP as it is "stream write". 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 ie used for TCP and cannot be used for UDP as it is "stream write".

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

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