diff --git a/include/uv.h b/include/uv.h index 705cc2ca..042944af 100644 --- a/include/uv.h +++ b/include/uv.h @@ -495,6 +495,13 @@ UV_EXTERN int uv_read2_start(uv_stream_t*, uv_alloc_cb alloc_cb, UV_EXTERN int uv_write(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt, uv_write_cb cb); +/* + * Extended write function for sending handles over a pipe. The pipe must be + * initialized with ipc == 1. + * send_handle must be a TCP socket or pipe, which is a server or a connection + * (listening or connected state). Bound sockets or pipes will be assumed to + * be servers. + */ UV_EXTERN int uv_write2(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt, uv_stream_t* send_handle, uv_write_cb cb); diff --git a/src/win/pipe.c b/src/win/pipe.c index e2e385cb..43aff626 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -1055,7 +1055,9 @@ static int uv_pipe_write_impl(uv_loop_t* loop, uv_write_t* req, } /* Only TCP handles are supported for sharing. */ - if (send_handle && send_handle->type != UV_TCP) { + if (send_handle && ((send_handle->type != UV_TCP) || + (!(send_handle->flags & UV_HANDLE_BOUND) && + !(send_handle->flags & UV_HANDLE_CONNECTION)))) { uv__set_artificial_error(loop, UV_ENOTSUP); return -1; }