GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  IO::ASYNC::PROTOCOL::LINESTREAM (3)

.ds Aq ’

NAME

"IO::Async::Protocol::LineStream" - stream-based protocols using lines of text

CONTENTS

SYNOPSIS

Most likely this class will be subclassed to implement a particular network protocol.



 package Net::Async::HelloWorld;

 use strict;
 use warnings;
 use base qw( IO::Async::Protocol::LineStream );

 sub on_read_line
 {
    my $self = shift;
    my ( $line ) = @_;

    if( $line =~ m/^HELLO (.*)/ ) {
       my $name = $1;

       $self->invoke_event( on_hello => $name );
    }
 }

 sub send_hello
 {
    my $self = shift;
    my ( $name ) = @_;

    $self->write_line( "HELLO $name" );
 }



This small example elides such details as error handling, which a real protocol implementation would be likely to contain.

DESCRIPTION

EVENTS

The following events are invoked, either using subclass methods or CODE references in parameters:

on_read_line CW$line

Invoked when a new complete line of input is received.

PARAMETERS

The following named parameters may be passed to new or configure:

    on_read_line => CODE

CODE reference for the on_read_line event.

METHODS

    write_line



   $lineprotocol->write_line( $text )



Writes a line of text to the transport stream. The text will have the end-of-line marker appended to it; $text should not end with it.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 IO::ASYNC::PROTOCOL::LINESTREAM (3) 2015-12-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.