Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Make it easy to do read(n, cb) #505

isaacs opened this Issue · 6 comments

4 participants


Part of the "make readable streams not terrible" project in Node.

18:24 <@isaacs> piscisaureus: how hard would it be to implement read(n, cb) in
                libuv?  in terms of days/weeks of work, etc.?
18:24 <@isaacs> any rough guess?
18:29 <@piscisaureus> isaacs: *shrug*, not much I suppose
18:29 <@piscisaureus> isaacs: it'd be uv_read_start, basically, but without
                      queuing a new read after reading
18:30 <@piscisaureus> you'd have to ask bnoordhuis for the unix details, but I
                      think we would have to remove the socket fd from the
                      poll set after a read returns. Which is also not that hard.
18:32 <@piscisaureus> uv_read(uv_handle_t*, uv_req_t*, size_t n, uv_alloc_cb
                      on_alloc, uv_read_cb on_read)
18:32 <@piscisaureus> ^— indutny ?
18:32 <@piscisaureus> ^— other libuv users?

@piscisaureus @bnoordhuis

ry commented

uv_err_t uv_read(uv_handle_t*, uv_req_t*, size_t n, uv_alloc_cb on_alloc, uv_read_cb on_read);

LGTM. Obviously this is not going to guarantee a read of n -- just at most n.


Why the uv_err_t return type?

ry commented

dead socket, etc


Isn't the usual to return -1 and use uv_last_error to get the error?


Closing old stalled issues, please reopen at if still needed.

@saghul saghul closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.