asio
asio copied to clipboard
support sendmmsg and recvmmsg
is there an plan to support sendmmsg and recvmmsg on unix platform? or WSARecvMsg on windows platform?we need "sendmmsg" or "recvmmsg" to realize aggregate sending and receiving data through udp socket
I'm finalizing a patch that does this and support it on Linux, QNX, (Open/Free/Net)BSD, AIX (and all that supports it). I'll proposing a primary patch release with this implementations in next days, that will need some work (adapt to < c++11, 'boostify' some parts, etc).
Any update to this? sendmmsg/recvmmsg would really be a nice feature for some applications.
I have the sources working on my github asio fork, in a branch.
Chris told this is not becoming the final interface in asio since need reworking done to support final asio release.
Its working on bsd / apple (i/mac)osx and linux.
You can currently use async_receive with null_buffers and then recvmmsg yourself inside the handler. I'm not sure how you might do something similar with async_send.
I look forward to a patch which implements this without workarounds like mine.
https://github.com/virgiliofornazin/asio/tree/feature/multiple_datagram_buffers_sequence-io-sendmmsg-recvmmsg
asio::resizeable_multiple_buffer_sequence<asio::mutable_buffer, asio::ip::tcp::endpoint> buffer_sequences; std::vector<std::vector<uint8_t>> buffer_vector;
buffer_vector.push_back(std::vector<uint8_t>{}); auto& buffer = buffer_vector.at(0);
buffer.resize(1500); asio::mutable_buffer asio_buffer(std::addressof(buffer.at(0)), buffer.size()); buffer_sequences.push_back(converted_buffer);
auto callback = [this](std::error_code const& error_code, size_t const bytes_transferred, size_t const operations_executed) mutable { // reenqueue_operations_pending(payloads);
// handle_send_multiple(error_code, bytes_transferred,
operations_executed, payloads); }; socket->async_send_multiple_buffer_sequence(buffer_sequences, callback);
On Sun, Feb 4, 2024 at 10:12 AM Mark Yang @.***> wrote:
You can currently use async_receive with null_buffers and then recvmmsg yourself inside the handler. I'm not sure how you might do something similar with async_send.
I look forward to a patch which implements this without workarounds like mine.
How did you do with workaround ? Could you give me a tip ?? I am trying to async_send with sendmmsg
— Reply to this email directly, view it on GitHub https://github.com/chriskohlhoff/asio/issues/1062#issuecomment-1925745029, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDEMZUI3ZICHLWT3BELGGLYR6CKFAVCNFSM5W4MVP42U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJSGU3TINJQGI4Q . You are receiving this because you commented.Message ID: @.***>
This interface is not optimal. I did it in a project I work and for my case, works perfectly because of allocation strategies and socket implementation. It must be reworked or serve as inspiration for a final implementation. Feel free to fork my project.
On Mon, Feb 5, 2024 at 7:24 PM Mark Yang @.***> wrote:
Thank you !! I will try this code. This feature is great !! When will this feature be integrated with the main boost version? I am excited about that.
— Reply to this email directly, view it on GitHub https://github.com/chriskohlhoff/asio/issues/1062#issuecomment-1928275002, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDEMZR23OIYJ2SO7SHKVJTYSFL2HAVCNFSM5W4MVP42U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJSHAZDONJQGAZA . You are receiving this because you commented.Message ID: @.***>
I will look into this and get back to you.
On Thu, Feb 8, 2024 at 9:02 AM Mark Yang @.***> wrote:
Thank you for your reply. But I have a question. below is an example code.
while (1) { auto bufs = new ba::resizeable_multiple_buffer_sequence<ba::mutable_buffer, ba::ip::udp::endpoint>; std::vector<uint8_t> bv0(1400); bufs->push_back(ba::mutable_buffer((PBYTE)bv0.data(), bv0.size()));
auto callback = [bufs](boost::system::error_code ec, size_t byteio, size_t ops) mutable { cout << "Completion : ec:"<<ec.value() <<" msg:"<<ec.message() << " " <<"byteio:"<<byteio<<" ops:"<<ops<<endl;
delete bufs;
if(ec.value()==55) sleep_ms(100); // MUST }; sock.async_send_multiple_buffer_sequence(*bufs, callback); }
For each IO call. I made muti_buffer_seq and deleted it in the completion handler. This code works very short time and crashes. with segmentation fault Is this usage wrong? Could you show me an example that sends dynamically new packets and cleans up in the completion handler?
— Reply to this email directly, view it on GitHub https://github.com/chriskohlhoff/asio/issues/1062#issuecomment-1933971303, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDEMZSK4XS5TJHHPEHCYCDYSS5GRAVCNFSM5W4MVP42U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJTGM4TOMJTGAZQ . You are receiving this because you commented.Message ID: @.***>
Ok, I'll check it out.
On Thu, Feb 8, 2024 at 4:32 PM Mark Yang @.***> wrote:
Sorry to bother you. I changed basic_datagram_socket.hpp:752 like below and seems fixed.. but not sure. Could you check this ?
//if (multiple_buffer_sequence.adjusted_count() > 1) if (multiple_buffer_sequence.adjusted_count() > 0) {
— Reply to this email directly, view it on GitHub https://github.com/chriskohlhoff/asio/issues/1062#issuecomment-1934807570, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDEMZTMU36K5PJXAQMURXDYSUR5DAVCNFSM5W4MVP42U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJTGQ4DANZVG4YA . You are receiving this because you commented.Message ID: @.***>
I know it makes a difference, but I didn`t need to implement it yet to support my demands. It changes a lot the way buffers are handled and I think it should be another implementation because the way it's done.
On Thu, Feb 15, 2024 at 6:05 PM Mark Yang @.***> wrote:
During using sendmmsg support feature. I bumped into some technique Generic Segmentation Offload (GSO). What do you think about this? Do you have a plan to adapt this?
— Reply to this email directly, view it on GitHub https://github.com/chriskohlhoff/asio/issues/1062#issuecomment-1947337552, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDEMZSCJY5S6NFQLQ3ZTZLYTZ2BDAVCNFSM5W4MVP42U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJUG4ZTGNZVGUZA . You are receiving this because you commented.Message ID: @.***>
RIO implementation needs a lot of redesign to make it work.
I never looked at WSASetUdpSendMessageLike.
On Sun, Feb 25, 2024 at 3:40 AM Mark Yang @.***> wrote:
Thanks to your great library I almost solved problems..Thank you. Just one question. For Windows..How can I do this multi-packet send job ? With RIO ? or WSASetUdpSendMessageSize ?
— Reply to this email directly, view it on GitHub https://github.com/chriskohlhoff/asio/issues/1062#issuecomment-1962832696, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDEMZUVUCYMMMXFMRBQFG3YVLMGXAVCNFSM5W4MVP42U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJWGI4DGMRWHE3A . You are receiving this because you commented.Message ID: @.***>
Since the "full" support is not ready apparently, I would appreciate if the low-level socket_ops parts could get merged on its own.