On Sat, Mar 24, 2018 at 4:51 AM, Ben Noordhuis <[email protected]> wrote:
> On Thu, Mar 22, 2018 at 11:32 PM, CM <[email protected]> wrote: > > To be more precise -- I wonder if you can get "gradual" buffer write > > notifications. I.e. as OS "drains" my buffer (writes it out to the > network) > > I'd like to receive notifications indicating how much of the buffer was > > written out. Is this possible with libuv (or Windows IOCP)? > > In general that's not possible. You could hack libuv's UNIX port to > give you that kind of notification but it won't work on Windows. > Hmm... Indeed, Unix "readiness" model (where you get notified of socket being "ready", write as much as can fit and wait for next notification) works very nicely here, but it leads to one extra memory copy (moving data from user buffer to socket buffer). IOCP model -- not so much, but it potentially enables zero-copy direct-memory protocol (where you register you buffer(s) and network card reads it directly). So for this to happen on Linux all I need is to "pierce" the "conversion layer" libuv put on top of readiness model for it to work like IOCP model. On Windows -- the only thing that comes to mind is to break every write request into 1-byte write requests :-) If only we had "buffer readiness" notification added to IOCP -- similar to how edge-triggered epoll works... I.e. once NIC sends out some data -- it updates "bytes sent" counter and (unless it is already set) sets the "alarm", once app receives notification about alarm -- it'll read counter, "disarm" alarm and do smth with (now free) buffer. Very similar to Unix readiness model, but instead of "socket buffer is ready to receive data" it means "your buffer is no longer needed". -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
