POE-0.26 > POE::Pipe::TwoWay

名前

POE::Pipe::TwoWay - portable two-way pipe creation (works without POE)

POE::Pipe::TwoWay - 移植可能な双方向パイプの生成(POE無しに動作)

概要

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

説明

POE::Pipe::TwoWay makes unbuffered two-way pipes or it dies trying. It can be more frugal with filehandles than two OneWay pipes when socketpair() is available.

POE::Pipe::TwoWayはバッファのない双方向のパイプを作るか挑戦して死にます。 socketpair()が利用可能なときは2つのOneWayパイプよりもファイルハンドルを 節約することができます。

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.

異なったパイプ生成メソッドはシステムごとにむらの多いサポートを持ってい るのでパイプはやっかいな獣です。pipe()を持っているシステムがあり、他 はsocketfactory()を持っており、いまだにどちらも持たないものもありま す。

POE::Pipe::TwoWay tries different ways to make a pipe in the hope that one of them will succeed on any given platform. It tries them in socketpair() -> pipe() -> IO::Socket::INET order. If socketpair() is available, the two-way pipe will use half as many filehandles as two one-way pipes.

POE::Pipe::TwoWayはパイプを作るためにどんな与えられたプラットフォーム上 でもどれか一つが動くことを期待して様々な方法を試します。それらは socketpair() -> pipe() -> IO::Socket::INETの順番で試されます。もし socketpair()が利用可能であれば、双方向パイプは2つの片方向パイプを使うの に比べて半分のファイルハンドルで済むでしょう。

So anyway, the syntax is pretty easy:

とにかく、構文はとても簡単です。

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

And now you have an unbuffered pipe with two read/write sides, A and B. Writing to $a_write passes data to $b_read, and writing to $b_write passes data to $a_read.

そしてAとBの2つの読み込み/書き込み側を持ったバッファのないパイプを手に 入れることができます。$a_writeへの書き込みは$b_readにデータが渡さ れ、$b_writeへの書き込みは$a_readにデータが渡されます。

DEBUGGING

It's possible to force POE::Pipe::TwoWay to use one of its underlying pipe methods. This was implemented for exercising each method in tests, but it's possibly useful for others.

POE::Pipe::TwoWayが内在するパイプメソッドの一つを使うように強制すること は可能です。それはテストで各メソッドを用いるために実装されましたが、も しかすると他のことにも役立つかもしれません。

However, forcing TwoWay's pipe method isn't documented because it's cheezy and likely to change. Use it at your own risk.

しかし、TwoWayのパイプメソッドの強制は粗末で変更されそうなのでドキュメ ント化されていません。自己責任で使用してください。

バグ

The INET domain socket method may block for up to 1s if it fails.

INETドメインソケットメソッドは失敗したとき最大1秒間ブロックするかもしれ ません。

AUTHOR & COPYRIGHT

POE::Pipe::TwoWay is copyright 2000 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.

Translators

井上 謙次 <deq@oct.zaq.ne.jp>