int uv_write(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb) { uv_loop_t* loop = handle->loop; int err; if (!(handle->flags & UV_HANDLE_WRITABLE)) { return UV_EPIPE; } err = ERROR_INVALID_PARAMETER; switch (handle->type) { case UV_TCP: err = uv_tcp_write(loop, req, (uv_tcp_t*) handle, bufs, nbufs, cb); break; case UV_NAMED_PIPE: err = uv_pipe_write(loop, req, (uv_pipe_t*) handle, bufs, nbufs, cb); break; case UV_TTY: err = uv_tty_write(loop, req, (uv_tty_t*) handle, bufs, nbufs, cb); break; default: assert(0); } return uv_translate_sys_error(err); }
int uv_write(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt, uv_write_cb cb) { switch (handle->type) { case UV_TCP: return uv_tcp_write(req, (uv_tcp_t*) handle, bufs, bufcnt, cb); case UV_NAMED_PIPE: return uv_pipe_write(req, (uv_pipe_t*) handle, bufs, bufcnt, cb); default: assert(0); uv_set_sys_error(WSAEINVAL); return -1; } }
int uv_write(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt, uv_write_cb cb) { uv_loop_t* loop = handle->loop; if (!(handle->flags & UV_HANDLE_WRITABLE)) { uv__set_artificial_error(loop, UV_EPIPE); return -1; } switch (handle->type) { case UV_TCP: return uv_tcp_write(loop, req, (uv_tcp_t*) handle, bufs, bufcnt, cb); case UV_NAMED_PIPE: return uv_pipe_write(loop, req, (uv_pipe_t*) handle, bufs, bufcnt, cb); case UV_TTY: return uv_tty_write(loop, req, (uv_tty_t*) handle, bufs, bufcnt, cb); default: assert(0); uv__set_sys_error(loop, WSAEINVAL); return -1; } }