NAME

POE::Pipe::TwoWay - a portable API for two-way pipes

SYNOPSIS

  my ($a_read, $a_write, $b_read, $b_write) = POE::Pipe::TwoWay->new();
  die "couldn't create a pipe: $!" unless defined $a_read;

DESCRIPTION

Pipes are troublesome beasts because there are a few different, incompatible ways to create them, and many operating systems implement some subset of them. Therefore it's impossible to rely on a particular method for their creation.

POE::Pipe::TwoWay will attempt to create a bidirectional pipe using an appropriate method. If that fails, it will fall back to some other means until success or all methods have been exhausted. Some operating systems require certain exceptions, which are hardcoded into the library.

The upshot of all this is that an application can use POE::Pipe::TwoWay to create a bidirectional pipe without worrying about the mechanism that works in the current run-time environment.

By the way, POE::Pipe::TwoWay doesn't use POE internally, so it may be used in stand-alone applications without POE.

PUBLIC METHODS

new [TYPE]

Create a new two-way pipe, optionally constraining it to a particular TYPE of pipe. Two-way pipes have two ends, both of which can be read from and written to. Therefore, a successful new() call will return four handles: read and write for one end, and read and write for the other. On failure, new() sets $! to describe the error and returns nothing.

  my ($a_read, $a_write, $b_read, $b_write) = POE::Pipe::TwoWay->new();
  die $! unless defined $a_read;

TYPE may be one of "pipe", "socketpair", or "inet". When set, POE::Pipe::TwoWay will constrain its search to either pipe(), a UNIX-domain socketpair(), or plain old sockets, respectively. Otherwise new() will try each method in order, or a particular method predetermined to be the best one for the current operating environment.

BUGS

POE::Pipe::OneWay may block up to one second on some systems if failure occurs while trying to create "inet" sockets.

SEE ALSO

POE::Pipe, POE::Pipe::OneWay.

AUTHOR & COPYRIGHT

POE::Pipe::TwoWay is copyright 2000-2008 by Rocco Caputo. All rights reserved. POE::Pipe::TwoWay is free software; you may redistribute it and/or modify it under the same terms as Perl itself.