The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

UV::Pipe - Pipe stream handles in libuv

SYNOPSIS

  #!/usr/bin/env perl
  use strict;
  use warnings;

  # A new stream handle will be initialised against the default loop
  my $pipe = UV::Pipe->new;

  $pipe->connect("server.sock", sub {
    say "Connected!";

    $pipe->write("Hello, server!\n");
  });

  # set up the data read callback
  $pipe->on(read => sub {
    my ($self, $err, $buf) = @_;
    say "More data: $buf";
  });
  $pipe->read_start();

DESCRIPTION

This module provides an interface to libuv's pipe stream handle.

Pipe handles represent a FIFO or UNIX ("local") socket.

EVENTS

UV::Pipe inherits all events from UV::Stream and UV::Handle.

METHODS

UV::Pipe inherits all methods from UV::Stream and UV::Handle and also makes the following extra methods available.

open

    $pipe->open($fh);

The open method associates the pipe with an existing filehandle already opened by the process.

bind

    $pipe->bind($path);

The bind method associates the pipe with a UNIX socket path or named filehandle, which will be created on the filesystem.

connect

    $pipe->connect($path, sub {
        my ($err) = @_;
        die "Cannot connect pipe - $err\n" if $err;

        say "The pipe is now connected";
    });

The connect method requests that the pipe be connected a server found on the given path.

On completion the callback is invoked. It is passed undef on success, or an error value on failure. This error value can be compared numerically to one of the UV_E* constants, or printed as a string to give a message.

getpeername

    my $path = $pipe->getpeername;

The getpeername method returns the filesystem path to which this pipe handle is connected.

getsockname

    my $path = $pipe->getsockname;

The getsockname method returns the filesystem path on which this pipe server handle is listening for incoming connections.

chmod

    $pipe->chmod($flags);

The chmod method sets the filesystem permissions on the named pipe or socket to allow access by other users. $flags should be a bitmask of UV_READABLE or UV_WRITABLE.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.