int uv_read_start(uv_stream_t* handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb) { int err; if (handle->flags & UV_HANDLE_READING) { return UV_EALREADY; } if (!(handle->flags & UV_HANDLE_READABLE)) { return UV_ENOTCONN; } err = ERROR_INVALID_PARAMETER; switch (handle->type) { case UV_TCP: err = uv_tcp_read_start((uv_tcp_t*)handle, alloc_cb, read_cb); break; case UV_NAMED_PIPE: err = uv_pipe_read_start((uv_pipe_t*)handle, alloc_cb, read_cb); break; case UV_TTY: err = uv_tty_read_start((uv_tty_t*) handle, alloc_cb, read_cb); break; default: assert(0); } return uv_translate_sys_error(err); }
int uv_read_start(uv_stream_t* handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb) { switch (handle->type) { case UV_TCP: return uv_tcp_read_start((uv_tcp_t*)handle, alloc_cb, read_cb); case UV_NAMED_PIPE: return uv_pipe_read_start((uv_pipe_t*)handle, alloc_cb, read_cb); default: assert(0); return -1; } }
int uv_read_start(uv_stream_t* handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb) { if (handle->flags & UV_HANDLE_READING) { uv__set_sys_error(handle->loop, UV_EALREADY); return -1; } if (!(handle->flags & UV_HANDLE_READABLE)) { uv__set_artificial_error(handle->loop, UV_ENOTCONN); return -1; } switch (handle->type) { case UV_TCP: return uv_tcp_read_start((uv_tcp_t*)handle, alloc_cb, read_cb); case UV_NAMED_PIPE: return uv_pipe_read_start((uv_pipe_t*)handle, alloc_cb, read_cb); case UV_TTY: return uv_tty_read_start((uv_tty_t*) handle, alloc_cb, read_cb); default: assert(0); return -1; } }