IO::As...eStream(3pm)

πŸ’– IO::Async::Protocol::LineStream πŸ’–

okay bestie, so this is the manual page for IO::Async::Protocol::LineStream β€” the IO::Async::Protocol::LineStream module, from the User Contributed Perl Documentation, living it up in section 3pm of the manual. And what does it do? stream-based protocols using lines of text. Let's get into it πŸ¦‹


✨ SYNOPSIS ✨

So like, most likely you're gonna subclass this class to build your actual network protocol β€” it's giving "starter kit, main character energy" πŸ‘‘

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" );
}

And just so you know: this tiny little example is eliding the error handling, bestie β€” a real protocol implementation would be likely to contain that. No cap, don't ship this exact snippet as your whole network stack πŸ™ˆ


πŸ“– DESCRIPTION πŸ“–

Yeah so… this section is literally empty in the original. Nothing here. A whole heading with no body. It's giving "blank notes app entry". Moving on πŸ’…


πŸŽ€ EVENTS πŸŽ€

These events get invoked, and you've got two vibes for hooking into them β€” either subclass methods, or CODE references passed in as parameters. Choose your fighter ✨

πŸ’œ on_read_line $line

Invoked when a new complete line of input is received. That's it, that's the moment 🫢


🌸 PARAMETERS 🌸

These named parameters can be passed to new or configure:

  • on_read_line => CODE β€” the CODE reference for the on_read_line event. Slap it in and you're wired up πŸ’–

🧚 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 β€” so $text should not end with it already, okay? Don't double up on the line ending, that's not the vibe 😭


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk> β€” the icon, the legend, the moment 🌈


and that's a wrap fr fr πŸ’… this page came to you courtesy of perl v5.40.1, dated 2026-02-21 β€” go off, and may all your lines arrive complete πŸŽ€βœ¨

πŸ“¦ where this page comes from