|
NAMEPOE::Driver - an abstract interface for buffered, non-blocking I/OSYNOPSISThis is a contrived example of how POE::Filter and POE::Driver objects may be used in a stand-alone application.my $driver = POE::Driver::SysRW->new(); my $filter = POE::Filter::Line->new(); my $list_of_octet_chunks = $filter->put("A line of text."); $driver->put( $list_of_octet_chunks ); my $octets_remaining_in_buffer = $driver->flush($filehandle); die "couldn't flush everything" if $octets_remaining_in_buffer; while (1) { my $octets_list = $driver->get($filehandle); die $! unless defined $octets_list; $filter->get_one_start($octets_list); while (my $line = $filter->get_one()) { print "Input: $line\n"; } } Most programs will use POE::Filter and POE::Driver objects as parameters to POE::Wheel constructors. See the synopses for particular classes for details. DESCRIPTIONPOE::Driver is a common API for I/O drivers that can read from and write to various files, sockets, pipes, and other devices.POE "drivers" implement the specifics of reading and writing to devices. Drivers plug into POE::Wheel objects so that wheels may support a large number of device types without implementing a separate subclass for each. As mentioned in the SYNOPSIS, POE::Driver objects may be used in stand-alone applications. Public Driver MethodsThese methods are the generic Driver interface, and every driver must implement them. Specific drivers may have additional methods related to their particular tasks.new new() creates, initializes, and returns a new driver. Specific drivers may have different constructor parameters. The default constructor parameters should configure the driver for the most common use case. get FILEHANDLE get() immediately tries to read information from a FILEHANDLE. It returns an array reference on success---even if nothing was read from the FILEHANDLE. get() returns undef on error, and $! will be set to the reason why get() failed. The returned arrayref will be empty if nothing was read from the FILEHANDLE. In an EOF condition, get() returns undef with the numeric value of $! set to zero. The arrayref returned by get() is suitable for passing to any POE::Filter's get() or get_one_start() method. Wheels do exactly this internally.
SEE ALSOThe SEE ALSO section in POE contains a table of contents covering the entire POE distribution.POE::Wheel - A base class for POE::Session mix-ins. POE::Filter - A base class for data parsers and serializers. POE::Driver::SysRW - A driver that encapsulates sysread() and buffered syswrite(). BUGSThere is no POE::Driver::SendRecv, but nobody has needed one so far. sysread() and syswrite() manage to do almost everything people need.In theory, drivers should be pretty much interchangeable. In practice, there seems to be an impermeable barrier between the different SOCK_* types. AUTHORS & COPYRIGHTSPlease see POE for more information about authors and contributors.
Visit the GSP FreeBSD Man Page Interface. |