Re: [asio-users] Are overlapping calls to async_write_some supported?
Brought to you by:
chris_kohlhoff
From: Florian P. <fg...@ph...> - 2013-01-16 11:49:34
|
On Jan16, 2013, at 11:42 , "Marat Abrarov" <ab...@ma...> wrote: >>> I think it's not so simple. What can you say about situation when send buffer of socket is too small (for buffer >>> specified by asyn_write_some/WSASend) or set to 0-size? >> >> The buffer will be filled with data. If the buffer is full, an error will happen. > > According to this logic I always get error for async_write_some with 0-size send buffer of socket. :) As far as I understand, the idea behind windows' overlapping I/O is that there need not be any OS-maintained buffer at all. Instead, WSASend() simply queues the I/O request *without* copying the data and delivers the completion notification once the data isn't needed anymore. If there *is* a OS-maintained buffer, e.g. the socket's send buffer, the completion handler is thus invoked once the data has been copied into that buffer. If there is *no* OS-maintained buffer, e.g. if the socket's send buffer is 0-sized, the completion handler is instead invoked once the data has been transmitted and acknowledged. The question thus isn't so much how large the send buffer is, but whether there's a limit on the number of outstanding I/O requests. And on unix-based systems, things seem to be quite different. There, asio uses non-blocking sockets together with readability/writability notifications (i.e, select/epoll/kqueue/whatever), and the OS thus isn't aware of how many asio operations are outstanding. So on these systems, the allowed number of overlapping async_write_some() calls should depend entirely on asio itself, not on the OS. I don't yet understand the code well enough though to figure that number out... Anyway, I think this whole area deserves more documentation. best regards, Florian Pflug |