On Jun 12, 7:01 pm, // ravi <[email protected]> wrote: > The part “data will be sent out in the future” suggests that Node/Streams is > holding the data and will send it out. Along with the description that “true” > indicates flush to underlying resource, it gives the impression that there is > no action needed. But if the "buffer is full” then where is the data being > held? One hopes somewhere else. But then moving on to the ‘drain’ event:
If you continue to write() after write() returns false but before 'drain' is emitted, the writes will be buffered in user memory (e.g. an array) because the kernel buffer is too full. > My question: what is the correct interpretation of this doc? > > (a) When writable.write() returns false, then the user should start buffering > up data until s/he receives a ‘drain’ event at which point writes can be > attempted again. It is the user’s responsibility to buffer on ‘false’ > (including for the chunk for which write() returned false). > > (b) The Stream interface will take care of saving the write()s somewhere even > when it returns false and the “data will be sent out in the future”. This > requires no action from the user and there is really no need to listen to > ‘drain’ for this reason. > > I suspect (a) is the case, but figured I would ask. It's (b). Although you may care to listen for 'drain' if you don't want to keep using up more and more memory. It should be noted that when piping streams, all of the listening for 'drain' and such is handled for you. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
