1POE::Pipe::TwoWay(3) User Contributed Perl Documentation POE::Pipe::TwoWay(3)
2
3
4
6 POE::Pipe::TwoWay - a portable API for two-way pipes
7
9 my ($a_read, $a_write, $b_read, $b_write) = POE::Pipe::TwoWay->new();
10 die "couldn't create a pipe: $!" unless defined $a_read;
11
13 Pipes are troublesome beasts because there are a few different,
14 incompatible ways to create them, and many operating systems implement
15 some subset of them. Therefore it's impossible to rely on a particular
16 method for their creation.
17
18 POE::Pipe::TwoWay will attempt to create a bidirectional pipe using an
19 appropriate method. If that fails, it will fall back to some other
20 means until success or all methods have been exhausted. Some operating
21 systems require certain exceptions, which are hardcoded into the
22 library.
23
24 The upshot of all this is that an application can use POE::Pipe::TwoWay
25 to create a bidirectional pipe without worrying about the mechanism
26 that works in the current run-time environment.
27
28 By the way, POE::Pipe::TwoWay doesn't use POE internally, so it may be
29 used in stand-alone applications without POE.
30
32 new [TYPE]
33 Create a new two-way pipe, optionally constraining it to a particular
34 TYPE of pipe. Two-way pipes have two ends, both of which can be read
35 from and written to. Therefore, a successful new() call will return
36 four handles: read and write for one end, and read and write for the
37 other. On failure, new() sets $! to describe the error and returns
38 nothing.
39
40 my ($a_read, $a_write, $b_read, $b_write) = POE::Pipe::TwoWay->new();
41 die $! unless defined $a_read;
42
43 TYPE may be one of "pipe", "socketpair", or "inet". When set,
44 POE::Pipe::TwoWay will constrain its search to either "pipe()", a UNIX-
45 domain "socketpair()", or plain old sockets, respectively. Otherwise
46 new() will try each method in order, or a particular method
47 predetermined to be the best one for the current operating environment.
48
50 POE::Pipe::OneWay may block up to one second on some systems if failure
51 occurs while trying to create "inet" sockets.
52
54 POE::Pipe, POE::Pipe::OneWay.
55
57 POE::Pipe::TwoWay is copyright 2000-2008 by Rocco Caputo. All rights
58 reserved. POE::Pipe::TwoWay is free software; you may redistribute it
59 and/or modify it under the same terms as Perl itself.
60
61
62
63perl v5.12.1 2010-04-03 POE::Pipe::TwoWay(3)