Module Luv__.Pipe
type t
= [ `Pipe ] Luv.Stream.t
Binds
uv_pipe_t
.Note that values of this type can also be used with functions in:
In particular, see
Luv.Handle.close
,Luv.Stream.accept
,Luv.Stream.read_start
,Luv.Stream.write
.
val init : ?loop:Luv.Loop.t -> ?for_handle_passing:bool -> unit -> (t, Luv.Error.t) Result.result
Allocates and initializes a pipe.
Binds
uv_pipe_init
.The pipe is not yet connected to anything at this point. See
Luv.Pipe.bind
,Luv.Stream.listen
, andLuv.Pipe.connect
.
val open_ : t -> Luv.File.t -> (unit, Luv.Error.t) Result.result
Wraps an existing file descriptor in a libuv pipe.
Binds
uv_pipe_open
.
val pipe : ?read_flags:Luv.TCP.Flag.t list -> ?write_flags:Luv.TCP.Flag.t list -> unit -> (Luv.File.t * Luv.File.t, Luv.Error.t) Result.result
Creates a pair of connected pipes.
In case of success, in the value
(read_pipe, write_pipe)
, data written towrite_pipe
can be read fromread_pipe
.?read_flags
specifies flags forread_pipe
. Likewise,?write_flags
specifies flags forwrite_pipe
. The only possible flag at the moment is`NONBLOCK
, which bindsUV_NONBLOCK_PIPE
. Both arguments are set to[`NONBLOCK]
by default.Requires Luv 0.5.7 and libuv 1.41.0.
Feature check:
Luv.Require.(has pipe)
val bind : t -> string -> (unit, Luv.Error.t) Result.result
Assigns a pipe a name or an address.
Binds
uv_pipe_bind
. Seebind(3p)
.
val connect : t -> string -> ((unit, Luv.Error.t) Result.result -> unit) -> unit
Connects to the pipe at the given name or address.
Binds
uv_pipe_connect
. Seeconnect(3p)
.
val getsockname : t -> (string, Luv.Error.t) Result.result
Retrieves the name or address assigned to the given pipe.
Binds
uv_pipe_getsockname
. Seegetsockname(3p)
.
val getpeername : t -> (string, Luv.Error.t) Result.result
Retrieves the name or address of the given pipe's peer.
Binds
uv_pipe_getpeername
. Seegetpeername(3p)
.
val pending_instances : t -> int -> unit
Binds
uv_pipe_pending_instances
.
val receive_handle : t -> [ `TCP of Luv.TCP.t -> (unit, Luv.Error.t) Result.result | `Pipe of t -> (unit, Luv.Error.t) Result.result | `None ]
Receives a file descriptor over the given pipe.
File descriptors are sent using the
~send_handle
argument ofLuv.Stream.write2
.On the receiving end, call
Luv.Stream.read_start
. When that function calls its callback, there may be file descriptors in the pipe, in addition to the ordinary data provided to the callback.To check, call this function
Luv.Pipe
.recieve_handle in a loop until it returns`None
. Each time it returns`TCP receive
or`Pipe receive
, create an appropriatehandle
using eitherLuv.TCP.init
orLuv.Pipe.init
, and callreceive handle
to receive the file descriptor and associate it withhandle
.
module Mode : sig ... end
Constants for
Luv.Pipe.chmod
.
val chmod : t -> Mode.t list -> (unit, Luv.Error.t) Result.result
Sets pipe permissions.
Binds
uv_pipe_chmod
.Requires libuv 1.16.0.
Feature check:
Luv.Require.(has pipe_chmod)