Any possibility to know if Stream has finished writing?
cursedcoder opened this issue · 8 comments
In Buffer
there's event full-drain
but it's not proxified on Stream
level.
https://github.com/cursedcoder/eprocess/blob/master/EProcess/Adapter/ChildProcess.php#L70
I'm using this to pass initial php code to interpreter and close this stream so php can execute it.
Sounds like the perfect use case for using end($data)
instead of write($data)
.
The end()
method will close the stream once the last byte has been sent.
Another case when communicating via unix socket data should be sent synchronously and you need full-drain to schedule messages.
I'd like to check this out, can you give a real world example on this use case?
@clue cursedcoder/emessenger@1623015
There is a red test when I'm trying to communicate more than 1 message at time.
https://travis-ci.org/cursedcoder/emessenger/jobs/123845117
I'm still curious because I've implemented quite a few protocols and have yet to come up with a reason to wait for the outgoing buffer to flush.
I'm not sure I follow this code, but it looks like the write()
s may be mixed up (see my comment on your commit).
Can you create a simple gist to exhibit this?
I believe this has been resolved?
FWIW, #16 (comment) also contains a possible workaround to use the full-drain
event to check when the outgoing buffer has been flushed.
I'm closing this due to lack of feedback for now, please feel free to report back if this persists and we can reopen this 👍