uv_pipe_t
— Pipe handle¶
Pipe handles provide an abstraction over streaming files on Unix (including local domain sockets, pipes, and FIFOs) and named pipes on Windows.
uv_pipe_t
is a ‘subclass’ of uv_stream_t
.
Data types¶
-
uv_pipe_t
¶ Pipe handle type.
Public members¶
-
int
uv_pipe_t.ipc
¶ Whether this pipe is suitable for handle passing between processes. Only a connected pipe that will be passing the handles should have this flag set, not the listening pipe that uv_accept is called on.
See also
The uv_stream_t
members also apply.
API¶
-
int
uv_pipe_init
(uv_loop_t* loop, uv_pipe_t* handle, int ipc)¶ Initialize a pipe handle. The ipc argument is a boolean to indicate if this pipe will be used for handle passing between processes (which may change the bytes on the wire). Only a connected pipe that will be passing the handles should have this flag set, not the listening pipe that uv_accept is called on.
-
int
uv_pipe_open
(uv_pipe_t* handle, uv_file file)¶ Open an existing file descriptor or HANDLE as a pipe.
Changed in version 1.2.1: the file descriptor is set to non-blocking mode.
Note
The passed file descriptor or HANDLE is not checked for its type, but it’s required that it represents a valid pipe.
-
int
uv_pipe_bind
(uv_pipe_t* handle, const char* name)¶ Bind the pipe to a file path (Unix) or a name (Windows).
Note
Paths on Unix get truncated to
sizeof(sockaddr_un.sun_path)
bytes, typically between 92 and 108 bytes.
-
void
uv_pipe_connect
(uv_connect_t* req, uv_pipe_t* handle, const char* name, uv_connect_cb cb)¶ Connect to the Unix domain socket or the named pipe.
Note
Paths on Unix get truncated to
sizeof(sockaddr_un.sun_path)
bytes, typically between 92 and 108 bytes.
-
int
uv_pipe_getsockname
(const uv_pipe_t* handle, char* buffer, size_t* size)¶ Get the name of the Unix domain socket or the named pipe.
A preallocated buffer must be provided. The size parameter holds the length of the buffer and it’s set to the number of bytes written to the buffer on output. If the buffer is not big enough
UV_ENOBUFS
will be returned and len will contain the required size.Changed in version 1.3.0: the returned length no longer includes the terminating null byte, and the buffer is not null terminated.
-
int
uv_pipe_getpeername
(const uv_pipe_t* handle, char* buffer, size_t* size)¶ Get the name of the Unix domain socket or the named pipe to which the handle is connected.
A preallocated buffer must be provided. The size parameter holds the length of the buffer and it’s set to the number of bytes written to the buffer on output. If the buffer is not big enough
UV_ENOBUFS
will be returned and len will contain the required size.New in version 1.3.0.
-
void
uv_pipe_pending_instances
(uv_pipe_t* handle, int count)¶ Set the number of pending pipe instance handles when the pipe server is waiting for connections.
Note
This setting applies to Windows only.
-
uv_handle_type
uv_pipe_pending_type
(uv_pipe_t* handle)¶ Used to receive handles over IPC pipes.
First - call
uv_pipe_pending_count()
, if it’s > 0 then initialize a handle of the given type, returned byuv_pipe_pending_type()
and calluv_accept(pipe, handle)
.
See also
The uv_stream_t
API functions also apply.
-
int
uv_pipe_chmod
(uv_pipe_t* handle, int flags)¶ Alters pipe permissions, allowing it to be accessed from processes run by different users. Makes the pipe writable or readable by all users. Mode can be
UV_WRITABLE
,UV_READABLE
orUV_WRITABLE | UV_READABLE
. This function is blocking.New in version 1.16.0.
-
int
uv_pipe
(uv_file fds[2], int read_flags, int write_flags)¶ Create a pair of connected pipe handles. Data may be written to fds[1] and read from fds[0]. The resulting handles can be passed to uv_pipe_open, used with uv_spawn, or for any other purpose.
Valid values for flags are:
- UV_NONBLOCK_PIPE: Opens the specified socket handle for OVERLAPPED or FIONBIO/O_NONBLOCK I/O usage. This is recommended for handles that will be used by libuv, and not usually recommended otherwise.
Equivalent to pipe(2) with the O_CLOEXEC flag set.
New in version 1.41.0.