POE::Pipe::OneWay - portable one-way pipe creation |
POE::Pipe::OneWay - portable one-way pipe creation (works without POE)
my ($read, $write) = POE::Pipe::OneWay->new(); die "couldn't create a pipe: $!" unless defined $read;
POE::Pipe::OneWay makes unbuffered one-way pipes or it dies trying.
Pipes are troublesome beasts because the different pipe creation
methods have spotty support from one system to another. Some systems
have pipe()
, others have socketfactory()
, and still others have
neither.
POE::Pipe::OneWay tries different ways to make a pipe in the hope that
one of them will succeed on any given platform. It tries them in
pipe()
-> socketpair()
-> IO::Socket::INET order.
So anyway, the syntax is pretty easy:
my ($read, $write) = POE::Pipe::OneWay->new(); die "couldn't create a pipe: $!" unless defined $read;
And now you have a pipe with a read side and a write side.
my ($read, $write) = POE::Pipe::OneWay->new();
It's possible to force POE::Pipe::OneWay to use one of its underlying pipe methods. This was implemented for exercising each method in tests, but it's possibly useful for others.
However, forcing OneWay's pipe method isn't documented because it's cheezy and likely to change. Use it at your own risk.
The INET domain socket method may block for up to 1s if it fails.
POE::Pipe::OneWay is copyright 2000 by Rocco Caputo. All rights reserved. POE::Pipe::OneWay is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
POE::Pipe::OneWay - portable one-way pipe creation |