home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 May
/
Chip_2000-05_cd1.bin
/
zkuste
/
Perl
/
ActivePerl-5.6.0.613.msi
/
䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥
/
_93b89631cf026b97c0d57bda97dbf730
< prev
next >
Wrap
Text File
|
2000-03-23
|
6KB
|
142 lines
<HTML>
<HEAD>
<TITLE>POE::Filter - POE Protocol Abstraction</TITLE>
<LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
<LINK REV="made" HREF="mailto:">
</HEAD>
<BODY>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> POE::Filter - POE Protocol Abstraction</P></STRONG>
</TD></TR>
</TABLE>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
<LI><A HREF="#description">DESCRIPTION</A></LI>
<LI><A HREF="#public filter methods">PUBLIC FILTER METHODS</A></LI>
<LI><A HREF="#see also">SEE ALSO</A></LI>
<LI><A HREF="#bugs">BUGS</A></LI>
<LI><A HREF="#authors & copyrights">AUTHORS & COPYRIGHTS</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>POE::Filter - POE Protocol Abstraction</P>
<P>
<HR>
<H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
<UL>
<LI>Linux</LI>
<LI>Solaris</LI>
<LI>Windows</LI>
</UL>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
$filter = new POE::Filter::Something();
$arrayref_of_logical_chunks =
$filter->get($arrayref_of_raw_chunks_from_driver);
$arrayref_of_streamable_chunks_for_driver =
$filter->put($arrayref_of_logical_chunks);</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>Filters provide a generic interface for low and medium level
protocols. Wheels use this interface to communicate in different
protocols without necessarily having to know the details for each.</P>
<P>In theory, filters should be interchangeable. In practice, stream and
block protocols tend to be incompatible.</P>
<P>
<HR>
<H1><A NAME="public filter methods">PUBLIC FILTER METHODS</A></H1>
<P>These methods are the generic Filter interface. Specific filters may
have additional methods.</P>
<UL>
<LI>
POE::Filter::new()
<P>The <CODE>new()</CODE> method creates and initializes a new filter. Specific
filters may have different constructor parameters.</P>
<P></P>
<LI>
POE::Filter::get($arrayref_of_raw_chunks_from_driver)
<P>The <CODE>get()</CODE> method translates raw stream data into logical units. It
accepts a reference to an array of raw stream chunks as returned from
POE::Driver::get(). It returns a reference to an array of complete
logical data chunks. There may or may not be a 1:1 correspondence
between raw stream chunks and logical data chunks.</P>
<P>Some filters may buffer partial logical units until they are completed
in subsequent <CODE>get()</CODE> calls.</P>
<P>The <CODE>get()</CODE> method returns a reference to an empty array if the stream
doesn't include enough information for a complete logical unit.</P>
<P></P>
<LI>
POE::Filter::put($arrayref_of_logical_chunks)
<P>The <CODE>put()</CODE> method takes a reference to an array of logical data chunks.
It serializes them into streamable representations suitable for
POE::Driver::put(). It returns the raw streamable versions in a
different array reference.</P>
<P></P>
<LI>
POE::Filter::get_pending()
<P>The <CODE>get_pending()</CODE> method is part of wheels' buffer swapping mechanism.
It clears the filter's input buffer and returns a copy of whatever was
in it. It doesn't manipulate filters' output buffers because they
don't exist (filters expect to receive entire logical data chunks from
sessions, so there's no reason to buffer data and frame it).</P>
<P><STRONG>Please note that relying on the get_pending() method in networked
settings require some forethought.</STRONG> For instance, POE::Filter::Stream
never buffers data.</P>
<P>Switching filters usually requires some sort of flow control,
otherwise it's easy to cause a race condition where one side sends the
wrong type of information for the other side's current filter.
Framing errors will ensue. Consider the following:</P>
<P>Assume a server and client are using POE::Filter::Line. When the
client asks the server to switch to POE::Filter::Reference, it should
wait for the server's ACK or NAK before changing its own filter. This
lets the client avoid sending referenced data while the server still
is parsing lines.</P>
<P>Here's something else to consider. Programs using POE::Wheel::put()
on TCP sockets cannot rely on each put data chunk arriving separately
on the receiving end of the connection. This is because TCP coalesces
packets whenever possible, to minimize packet header overhead.</P>
<P>Most systems have a way to disable the TCP delay (Nagle's algorithm),
in one form or another. If you need this, please check your C headers
for the TCP_NODELAY socket option. It's neither portable, nor
supported in Perl by default.</P>
<P>The filterchange.perl sample program copes with flow control while
switching filters.</P>
<P></P></UL>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P>POE::Filter::HTTPD; POE::Filter::Line; POE::Filter::Reference;
POE::Filter::Stream</P>
<P>
<HR>
<H1><A NAME="bugs">BUGS</A></H1>
<P>Oh, probably some.</P>
<P>
<HR>
<H1><A NAME="authors & copyrights">AUTHORS & COPYRIGHTS</A></H1>
<P>Please see the POE manpage.</P>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> POE::Filter - POE Protocol Abstraction</P></STRONG>
</TD></TR>
</TABLE>
</BODY>
</HTML>