Blame docs/src/pipe.rst

Packit b5b901
Packit b5b901
.. _pipe:
Packit b5b901
Packit b5b901
:c:type:`uv_pipe_t` --- Pipe handle
Packit b5b901
===================================
Packit b5b901
Packit Service e08953
Pipe handles provide an abstraction over streaming files on Unix (including
Packit Service e08953
local domain sockets, pipes, and FIFOs) and named pipes on Windows.
Packit b5b901
Packit b5b901
:c:type:`uv_pipe_t` is a 'subclass' of :c:type:`uv_stream_t`.
Packit b5b901
Packit b5b901
Packit b5b901
Data types
Packit b5b901
----------
Packit b5b901
Packit b5b901
.. c:type:: uv_pipe_t
Packit b5b901
Packit b5b901
    Pipe handle type.
Packit b5b901
Packit b5b901
Packit b5b901
Public members
Packit b5b901
^^^^^^^^^^^^^^
Packit b5b901
Packit b5b901
.. c:member:: int uv_pipe_t.ipc
Packit b5b901
Packit b5b901
    Whether this pipe is suitable for handle passing between processes.
Packit Service e08953
    Only a connected pipe that will be passing the handles should have this flag
Packit Service e08953
    set, not the listening pipe that uv_accept is called on.
Packit b5b901
Packit b5b901
.. seealso:: The :c:type:`uv_stream_t` members also apply.
Packit b5b901
Packit b5b901
Packit b5b901
API
Packit b5b901
---
Packit b5b901
Packit b5b901
.. c:function:: int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc)
Packit b5b901
Packit b5b901
    Initialize a pipe handle. The `ipc` argument is a boolean to indicate if
Packit Service e08953
    this pipe will be used for handle passing between processes (which may
Packit Service e08953
    change the bytes on the wire). Only a connected pipe that will be
Packit Service e08953
    passing the handles should have this flag set, not the listening pipe
Packit Service e08953
    that uv_accept is called on.
Packit b5b901
Packit b5b901
.. c:function:: int uv_pipe_open(uv_pipe_t* handle, uv_file file)
Packit b5b901
Packit b5b901
    Open an existing file descriptor or HANDLE as a pipe.
Packit b5b901
Packit b5b901
    .. versionchanged:: 1.2.1 the file descriptor is set to non-blocking mode.
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        The passed file descriptor or HANDLE is not checked for its type, but
Packit b5b901
        it's required that it represents a valid pipe.
Packit b5b901
Packit b5b901
.. c:function:: int uv_pipe_bind(uv_pipe_t* handle, const char* name)
Packit b5b901
Packit b5b901
    Bind the pipe to a file path (Unix) or a name (Windows).
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between
Packit b5b901
        92 and 108 bytes.
Packit b5b901
Packit b5b901
.. c:function:: void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, const char* name, uv_connect_cb cb)
Packit b5b901
Packit b5b901
    Connect to the Unix domain socket or the named pipe.
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between
Packit b5b901
        92 and 108 bytes.
Packit b5b901
Packit b5b901
.. c:function:: int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Get the name of the Unix domain socket or the named pipe.
Packit b5b901
Packit b5b901
    A preallocated buffer must be provided. The size parameter holds the length
Packit b5b901
    of the buffer and it's set to the number of bytes written to the buffer on
Packit b5b901
    output. If the buffer is not big enough ``UV_ENOBUFS`` will be returned and
Packit b5b901
    len will contain the required size.
Packit b5b901
Packit b5b901
    .. versionchanged:: 1.3.0 the returned length no longer includes the terminating null byte,
Packit b5b901
                        and the buffer is not null terminated.
Packit b5b901
Packit b5b901
.. c:function:: int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Get the name of the Unix domain socket or the named pipe to which the handle
Packit b5b901
    is connected.
Packit b5b901
Packit b5b901
    A preallocated buffer must be provided. The size parameter holds the length
Packit b5b901
    of the buffer and it's set to the number of bytes written to the buffer on
Packit b5b901
    output. If the buffer is not big enough ``UV_ENOBUFS`` will be returned and
Packit b5b901
    len will contain the required size.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.3.0
Packit b5b901
Packit b5b901
.. c:function:: void uv_pipe_pending_instances(uv_pipe_t* handle, int count)
Packit b5b901
Packit b5b901
    Set the number of pending pipe instance handles when the pipe server is
Packit b5b901
    waiting for connections.
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        This setting applies to Windows only.
Packit b5b901
Packit b5b901
.. c:function:: int uv_pipe_pending_count(uv_pipe_t* handle)
Packit b5b901
.. c:function:: uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle)
Packit b5b901
Packit b5b901
    Used to receive handles over IPC pipes.
Packit b5b901
Packit b5b901
    First - call :c:func:`uv_pipe_pending_count`, if it's > 0 then initialize
Packit b5b901
    a handle of the given `type`, returned by :c:func:`uv_pipe_pending_type`
Packit b5b901
    and call ``uv_accept(pipe, handle)``.
Packit b5b901
Packit b5b901
.. seealso:: The :c:type:`uv_stream_t` API functions also apply.
Packit b5b901
Packit b5b901
.. c:function:: int uv_pipe_chmod(uv_pipe_t* handle, int flags)
Packit b5b901
Packit b5b901
    Alters pipe permissions, allowing it to be accessed from processes run by
Packit b5b901
    different users. Makes the pipe writable or readable by all users. Mode can
Packit b5b901
    be ``UV_WRITABLE``, ``UV_READABLE`` or ``UV_WRITABLE | UV_READABLE``. This
Packit b5b901
    function is blocking.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.16.0