1IO::Async::Stream(3) User Contributed Perl Documentation IO::Async::Stream(3)
2
3
4
6 "IO::Async::Stream" - event callbacks and write bufering for a stream
7 filehandle
8
10 use IO::Async::Stream;
11
12 use IO::Async::Loop;
13 my $loop = IO::Async::Loop->new;
14
15 my $stream = IO::Async::Stream->new(
16 read_handle => \*STDIN,
17 write_handle => \*STDOUT,
18
19 on_read => sub {
20 my ( $self, $buffref, $eof ) = @_;
21
22 while( $$buffref =~ s/^(.*\n)// ) {
23 print "Received a line $1";
24 }
25
26 if( $eof ) {
27 print "EOF; last partial line is $$buffref\n";
28 }
29
30 return 0;
31 }
32 );
33
34 $loop->add( $stream );
35
36 $stream->write( "An initial line here\n" );
37
39 This subclass of IO::Async::Handle contains a filehandle that
40 represents a byte-stream. It provides buffering for both incoming and
41 outgoing data. It invokes the "on_read" handler when new data is read
42 from the filehandle. Data may be written to the filehandle by calling
43 the "write" method.
44
45 This class is suitable for any kind of filehandle that provides a
46 possibly-bidirectional reliable byte stream, such as a pipe, TTY, or
47 "SOCK_STREAM" socket (such as TCP or a byte-oriented UNIX local
48 socket). For datagram or raw message-based sockets (such as UDP) see
49 instead IO::Async::Socket.
50
52 The following events are invoked, either using subclass methods or CODE
53 references in parameters:
54
55 $ret = on_read \$buffer, $eof
56 Invoked when more data is available in the internal receiving buffer.
57
58 The first argument is a reference to a plain perl string. The code
59 should inspect and remove any data it likes, but is not required to
60 remove all, or indeed any of the data. Any data remaining in the buffer
61 will be preserved for the next call, the next time more data is
62 received from the handle.
63
64 In this way, it is easy to implement code that reads records of some
65 form when completed, but ignores partially-received records, until all
66 the data is present. If the handler wishes to be immediately invoke a
67 second time, to have another attempt at consuming more content, it
68 should return 1. Otherwise, it should return 0, and the handler will
69 next be invoked when more data has arrived from the underlying read
70 handle and appended to the buffer. This makes it easy to implement code
71 that handles multiple incoming records at the same time. Alternatively,
72 if the handler function already attempts to consume as much as possible
73 from the buffer, it will have no need to return 1 at all. See the
74 examples at the end of this documentation for more detail.
75
76 The second argument is a scalar indicating whether the stream has
77 reported an end-of-file (EOF) condition. A reference to the buffer is
78 passed to the handler in the usual way, so it may inspect data
79 contained in it. Once the handler returns a false value, it will not be
80 called again, as the handle is now at EOF and no more data can arrive.
81
82 The "on_read" code may also dynamically replace itself with a new
83 callback by returning a CODE reference instead of 0 or 1. The original
84 callback or method that the object first started with may be restored
85 by returning "undef". Whenever the callback is changed in this way, the
86 new code is called again; even if the read buffer is currently empty.
87 See the examples at the end of this documentation for more detail.
88
89 The "push_on_read" method can be used to insert new, temporary handlers
90 that take precedence over the global "on_read" handler. This event is
91 only used if there are no further pending handlers created by
92 "push_on_read".
93
94 on_read_eof
95 Optional. Invoked when the read handle indicates an end-of-file (EOF)
96 condition. If there is any data in the buffer still to be processed,
97 the "on_read" event will be invoked first, before this one.
98
99 on_write_eof
100 Optional. Invoked when the write handle indicates an end-of-file (EOF)
101 condition. Note that this condition can only be detected after a
102 "write" syscall returns the "EPIPE" error. If there is no data pending
103 to be written then it will not be detected yet.
104
105 on_read_error $errno
106 Optional. Invoked when the "sysread" method on the read handle fails.
107
108 on_write_error $errno
109 Optional. Invoked when the "syswrite" method on the write handle fails.
110
111 The "on_read_error" and "on_write_error" handlers are passed the value
112 of $! at the time the error occurred. (The $! variable itself, by its
113 nature, may have changed from the original error by the time this
114 handler runs so it should always use the value passed in).
115
116 If an error occurs when the corresponding error callback is not
117 supplied, and there is not a handler for it, then the "close" method is
118 called instead.
119
120 on_read_high_watermark $length
121 on_read_low_watermark $length
122 Optional. Invoked when the read buffer grows larger than the high
123 watermark or smaller than the low watermark respectively. These are
124 edge-triggered events; they will only be triggered once per crossing,
125 not continuously while the buffer remains above or below the given
126 limit.
127
128 If these event handlers are not defined, the default behaviour is to
129 disable read-ready notifications if the read buffer grows larger than
130 the high watermark (so as to avoid it growing arbitrarily if nothing is
131 consuming it), and re-enable notifications again once something has
132 read enough to cause it to drop. If these events are overridden, the
133 overriding code will have to perform this behaviour if required, by
134 using
135
136 $self->want_readready_for_read(...)
137
138 on_outgoing_empty
139 Optional. Invoked when the writing data buffer becomes empty.
140
141 on_writeable_start
142 on_writeable_stop
143 Optional. These two events inform when the filehandle becomes
144 writeable, and when it stops being writeable. "on_writeable_start" is
145 invoked by the "on_write_ready" event if previously it was known to be
146 not writeable. "on_writeable_stop" is invoked after a "syswrite"
147 operation fails with "EAGAIN" or "EWOULDBLOCK". These two events track
148 the writeability state, and ensure that only state change cause events
149 to be invoked. A stream starts off being presumed writeable, so the
150 first of these events to be observed will be "on_writeable_stop".
151
153 The following named parameters may be passed to "new" or "configure":
154
155 read_handle => IO
156 The IO handle to read from. Must implement "fileno" and "sysread"
157 methods.
158
159 write_handle => IO
160 The IO handle to write to. Must implement "fileno" and "syswrite"
161 methods.
162
163 handle => IO
164 Shortcut to specifying the same IO handle for both of the above.
165
166 on_read => CODE
167 on_read_error => CODE
168 on_outgoing_empty => CODE
169 on_write_error => CODE
170 on_writeable_start => CODE
171 on_writeable_stop => CODE
172 CODE references for event handlers.
173
174 autoflush => BOOL
175 Optional. If true, the "write" method will attempt to write data to the
176 operating system immediately, without waiting for the loop to indicate
177 the filehandle is write-ready. This is useful, for example, on streams
178 that should contain up-to-date logging or console information.
179
180 It currently defaults to false for any file handle, but future versions
181 of IO::Async may enable this by default on STDOUT and STDERR.
182
183 read_len => INT
184 Optional. Sets the buffer size for "read" calls. Defaults to 8 KiBytes.
185
186 read_all => BOOL
187 Optional. If true, attempt to read as much data from the kernel as
188 possible when the handle becomes readable. By default this is turned
189 off, meaning at most one fixed-size buffer is read. If there is still
190 more data in the kernel's buffer, the handle will still be readable,
191 and will be read from again.
192
193 This behaviour allows multiple streams and sockets to be multiplexed
194 simultaneously, meaning that a large bulk transfer on one cannot starve
195 other filehandles of processing time. Turning this option on may
196 improve bulk data transfer rate, at the risk of delaying or stalling
197 processing on other filehandles.
198
199 write_len => INT
200 Optional. Sets the buffer size for "write" calls. Defaults to 8
201 KiBytes.
202
203 write_all => BOOL
204 Optional. Analogous to the "read_all" option, but for writing. When
205 "autoflush" is enabled, this option only affects deferred writing if
206 the initial attempt failed due to buffer space.
207
208 read_high_watermark => INT
209 read_low_watermark => INT
210 Optional. If defined, gives a way to implement flow control or other
211 behaviours that depend on the size of Stream's read buffer.
212
213 If after more data is read from the underlying filehandle the read
214 buffer is now larger than the high watermark, the
215 "on_read_high_watermark" event is triggered (which, by default, will
216 disable read-ready notifications and pause reading from the
217 filehandle).
218
219 If after data is consumed by an "on_read" handler the read buffer is
220 now smaller than the low watermark, the "on_read_low_watermark" event
221 is triggered (which, by default, will re-enable read-ready
222 notifications and resume reading from the filehandle). For to be
223 possible, the read handler would have to be one added by the
224 "push_on_read" method or one of the Future-returning "read_*" methods.
225
226 By default these options are not defined, so this behaviour will not
227 happen. "read_low_watermark" may not be set to a larger value than
228 "read_high_watermark", but it may be set to a smaller value, creating a
229 hysteresis region. If either option is defined then both must be.
230
231 If these options are used with the default event handlers, be careful
232 not to cause deadlocks by having a high watermark sufficiently low that
233 a single "on_read" invocation might not consider it finished yet.
234
235 reader => STRING|CODE
236 writer => STRING|CODE
237 Optional. If defined, gives the name of a method or a CODE reference to
238 use to implement the actual reading from or writing to the filehandle.
239 These will be invoked as
240
241 $stream->reader( $read_handle, $buffer, $len )
242 $stream->writer( $write_handle, $buffer, $len )
243
244 Each is expected to modify the passed buffer; "reader" by appending to
245 it, "writer" by removing a prefix from it. Each is expected to return a
246 true value on success, zero on EOF, or "undef" with $! set for errors.
247 If not provided, they will be substituted by implenentations using
248 "sysread" and "syswrite" on the underlying handle, respectively.
249
250 close_on_read_eof => BOOL
251 Optional. Usually true, but if set to a false value then the stream
252 will not be "close"d when an EOF condition occurs on read. This is
253 normally not useful as at that point the underlying stream filehandle
254 is no longer useable, but it may be useful for reading regular files,
255 or interacting with TTY devices.
256
257 encoding => STRING
258 If supplied, sets the name of encoding of the underlying stream. If an
259 encoding is set, then the "write" method will expect to receive Unicode
260 strings and encodes them into bytes, and incoming bytes will be decoded
261 into Unicode strings for the "on_read" event.
262
263 If an encoding is not supplied then "write" and "on_read" will work in
264 byte strings.
265
266 IMPORTANT NOTE: in order to handle reads of UTF-8 content or other
267 multibyte encodings, the code implementing the "on_read" event uses a
268 feature of Encode; the "STOP_AT_PARTIAL" flag. While this flag has
269 existed for a while and is used by the ":encoding" PerlIO layer itself
270 for similar purposes, the flag is not officially documented by the
271 "Encode" module. In principle this undocumented feature could be
272 subject to change, in practice I believe it to be reasonably stable.
273
274 This note applies only to the "on_read" event; data written using the
275 "write" method does not rely on any undocumented features of "Encode".
276
277 If a read handle is given, it is required that either an "on_read"
278 callback reference is configured, or that the object provides an
279 "on_read" method. It is optional whether either is true for
280 "on_outgoing_empty"; if neither is supplied then no action will be
281 taken when the writing buffer becomes empty.
282
283 An "on_read" handler may be supplied even if no read handle is yet
284 given, to be used when a read handle is eventually provided by the
285 "set_handles" method.
286
287 This condition is checked at the time the object is added to a Loop; it
288 is allowed to create a "IO::Async::Stream" object with a read handle
289 but without a "on_read" handler, provided that one is later given using
290 "configure" before the stream is added to its containing Loop, either
291 directly or by being a child of another Notifier already in a Loop, or
292 added to one.
293
295 The following methods documented with a trailing call to "->get" return
296 Future instances.
297
298 want_readready_for_read
299 want_readready_for_write
300 $stream->want_readready_for_read( $set )
301
302 $stream->want_readready_for_write( $set )
303
304 Mutators for the "want_readready" property on IO::Async::Handle, which
305 control whether the "read" or "write" behaviour should be continued
306 once the filehandle becomes ready for read.
307
308 Normally, "want_readready_for_read" is always true (though the read
309 watermark behaviour can modify it), and "want_readready_for_write" is
310 not used. However, if a custom "writer" function is provided, it may
311 find this useful for being invoked again if it cannot proceed with a
312 write operation until the filehandle becomes readable (such as during
313 transport negotiation or SSL key management, for example).
314
315 want_writeready_for_read
316 want_writeready_for_write
317 $stream->want_writeready_for_write( $set )
318
319 $stream->want_writeready_for_read( $set )
320
321 Mutators for the "want_writeready" property on IO::Async::Handle, which
322 control whether the "write" or "read" behaviour should be continued
323 once the filehandle becomes ready for write.
324
325 Normally, "want_writeready_for_write" is managed by the "write" method
326 and associated flushing, and "want_writeready_for_read" is not used.
327 However, if a custom "reader" function is provided, it may find this
328 useful for being invoked again if it cannot proceed with a read
329 operation until the filehandle becomes writable (such as during
330 transport negotiation or SSL key management, for example).
331
332 close
333 $stream->close
334
335 A synonym for "close_when_empty". This should not be used when the
336 deferred wait behaviour is required, as the behaviour of "close" may
337 change in a future version of IO::Async. Instead, call
338 "close_when_empty" directly.
339
340 close_when_empty
341 $stream->close_when_empty
342
343 If the write buffer is empty, this method calls "close" on the
344 underlying IO handles, and removes the stream from its containing loop.
345 If the write buffer still contains data, then this is deferred until
346 the buffer is empty. This is intended for "write-then-close" one-shot
347 streams.
348
349 $stream->write( "Here is my final data\n" );
350 $stream->close_when_empty;
351
352 Because of this deferred nature, it may not be suitable for error
353 handling. See instead the "close_now" method.
354
355 close_now
356 $stream->close_now
357
358 This method immediately closes the underlying IO handles and removes
359 the stream from the containing loop. It will not wait to flush the
360 remaining data in the write buffer.
361
362 is_read_eof
363 is_write_eof
364 $eof = $stream->is_read_eof
365
366 $eof = $stream->is_write_eof
367
368 Returns true after an EOF condition is reported on either the read or
369 the write handle, respectively.
370
371 write
372 $stream->write( $data, %params )
373
374 This method adds data to the outgoing data queue, or writes it
375 immediately, according to the "autoflush" parameter.
376
377 If the "autoflush" option is set, this method will try immediately to
378 write the data to the underlying filehandle. If this completes
379 successfully then it will have been written by the time this method
380 returns. If it fails to write completely, then the data is queued as if
381 "autoflush" were not set, and will be flushed as normal.
382
383 $data can either be a plain string, a Future, or a CODE reference. If
384 it is a plain string it is written immediately. If it is not, its value
385 will be used to generate more $data values, eventually leading to
386 strings to be written.
387
388 If $data is a "Future", the Stream will wait until it is ready, and
389 take the single value it yields.
390
391 If $data is a CODE reference, it will be repeatedly invoked to generate
392 new values. Each time the filehandle is ready to write more data to it,
393 the function is invoked. Once the function has finished generating data
394 it should return undef. The function is passed the Stream object as its
395 first argument.
396
397 It is allowed that "Future"s yield CODE references, or CODE references
398 return "Future"s, as well as plain strings.
399
400 For example, to stream the contents of an existing opened filehandle:
401
402 open my $fileh, "<", $path or die "Cannot open $path - $!";
403
404 $stream->write( sub {
405 my ( $stream ) = @_;
406
407 sysread $fileh, my $buffer, 8192 or return;
408 return $buffer;
409 } );
410
411 Takes the following optional named parameters in %params:
412
413 write_len => INT
414 Overrides the "write_len" parameter for the data written by
415 this call.
416
417 on_write => CODE
418 A CODE reference which will be invoked after every successful
419 "syswrite" operation on the underlying filehandle. It will be
420 passed the number of bytes that were written by this call,
421 which may not be the entire length of the buffer - if it takes
422 more than one "syscall" operation to empty the buffer then this
423 callback will be invoked multiple times.
424
425 $on_write->( $stream, $len )
426
427 on_flush => CODE
428 A CODE reference which will be invoked once the data queued by
429 this "write" call has been flushed. This will be invoked even
430 if the buffer itself is not yet empty; if more data has been
431 queued since the call.
432
433 $on_flush->( $stream )
434
435 on_error => CODE
436 A CODE reference which will be invoked if a "syswrite" error
437 happens while performing this write. Invoked as for the
438 "Stream"'s "on_write_error" event.
439
440 $on_error->( $stream, $errno )
441
442 If the object is not yet a member of a loop and doesn't yet have a
443 "write_handle", then calls to the "write" method will simply queue the
444 data and return. It will be flushed when the object is added to the
445 loop.
446
447 If $data is a defined but empty string, the write is still queued, and
448 the "on_flush" continuation will be invoked, if supplied. This can be
449 used to obtain a marker, to invoke some code once the output queue has
450 been flushed up to this point.
451
452 write (scalar)
453 $stream->write( ... )->get
454
455 If called in non-void context, this method returns a Future which will
456 complete (with no value) when the write operation has been flushed.
457 This may be used as an alternative to, or combined with, the "on_flush"
458 callback.
459
460 push_on_read
461 $stream->push_on_read( $on_read )
462
463 Pushes a new temporary "on_read" handler to the end of the queue. This
464 queue, if non-empty, is used to provide "on_read" event handling code
465 in preference to using the object's main event handler or method. New
466 handlers can be supplied at any time, and they will be used in first-in
467 first-out (FIFO) order.
468
469 As with the main "on_read" event handler, each can return a (defined)
470 boolean to indicate if they wish to be invoked again or not, another
471 "CODE" reference to replace themself with, or "undef" to indicate it is
472 now complete and should be removed. When a temporary handler returns
473 "undef" it is shifted from the queue and the next one, if present, is
474 invoked instead. If there are no more then the object's main handler is
475 invoked instead.
476
478 The following methods all return a Future which will become ready when
479 enough data has been read by the Stream into its buffer. At this point,
480 the data is removed from the buffer and given to the "Future" object to
481 complete it.
482
483 my $f = $stream->read_...
484
485 my ( $string ) = $f->get;
486
487 Unlike the "on_read" event handlers, these methods don't allow for
488 access to "partial" results; they only provide the final result once it
489 is ready.
490
491 If a "Future" is cancelled before it completes it is removed from the
492 read queue without consuming any data; i.e. each "Future" atomically
493 either completes or is cancelled.
494
495 Since it is possible to use a readable "Stream" entirely using these
496 "Future"-returning methods instead of the "on_read" event, it may be
497 useful to configure a trivial return-false event handler to keep it
498 from consuming any input, and to allow it to be added to a "Loop" in
499 the first place.
500
501 my $stream = IO::Async::Stream->new( on_read => sub { 0 }, ... );
502 $loop->add( $stream );
503
504 my $f = $stream->read_...
505
506 If a read EOF or error condition happens while there are read "Future"s
507 pending, they are all completed. In the case of a read EOF, they are
508 done with "undef"; in the case of a read error they are failed using
509 the $! error value as the failure.
510
511 $f->fail( $message, sysread => $! )
512
513 If a read EOF condition happens to the currently-processing read
514 "Future", it will return a partial result. The calling code can detect
515 this by the fact that the returned data is not complete according to
516 the specification (too short in "read_exactly"'s case, or lacking the
517 ending pattern in "read_until"'s case). Additionally, each "Future"
518 will yield the $eof value in its results.
519
520 my ( $string, $eof ) = $f->get;
521
522 read_atmost
523 read_exactly
524 ( $string, $eof ) = $stream->read_atmost( $len )->get
525
526 ( $string, $eof ) = $stream->read_exactly( $len )->get
527
528 Completes the "Future" when the read buffer contains $len or more
529 characters of input. "read_atmost" will also complete after the first
530 invocation of "on_read", even if fewer characters are available,
531 whereas "read_exactly" will wait until at least $len are available.
532
533 read_until
534 ( $string, $eof ) = $stream->read_until( $end )->get
535
536 Completes the "Future" when the read buffer contains a match for $end,
537 which may either be a plain string or a compiled "Regexp" reference.
538 Yields the prefix of the buffer up to and including this match.
539
540 read_until_eof
541 ( $string, $eof ) = $stream->read_until_eof->get
542
543 Completes the "Future" when the stream is eventually closed at EOF, and
544 yields all of the data that was available.
545
547 new_for_stdin
548 new_for_stdout
549 new_for_stdio
550 $stream = IO::Async::Stream->new_for_stdin
551
552 $stream = IO::Async::Stream->new_for_stdout
553
554 $stream = IO::Async::Stream->new_for_stdio
555
556 Return a "IO::Async::Stream" object preconfigured with the correct
557 "read_handle", "write_handle" or both.
558
559 connect
560 $future = $stream->connect( %args )
561
562 A convenient wrapper for calling the "connect" method on the underlying
563 IO::Async::Loop object, passing the "socktype" hint as "stream" if not
564 otherwise supplied.
565
567 The following flags in "IO_ASYNC_DEBUG_FLAGS" enable extra logging:
568
569 "Sr"
570 Log byte buffers as data is read from a Stream
571
572 "Sw"
573 Log byte buffers as data is written to a Stream
574
576 A line-based "on_read" method
577 The following "on_read" method accepts incoming "\n"-terminated lines
578 and prints them to the program's "STDOUT" stream.
579
580 sub on_read
581 {
582 my $self = shift;
583 my ( $buffref, $eof ) = @_;
584
585 while( $$buffref =~ s/^(.*\n)// ) {
586 print "Received a line: $1";
587 }
588
589 return 0;
590 }
591
592 Because a reference to the buffer itself is passed, it is simple to use
593 a "s///" regular expression on the scalar it points at, to both check
594 if data is ready (i.e. a whole line), and to remove it from the buffer.
595 Since it always removes as many complete lines as possible, it doesn't
596 need invoking again when it has finished, so it can return a constant
597 0.
598
599 Reading binary data
600 This "on_read" method accepts incoming records in 16-byte chunks,
601 printing each one.
602
603 sub on_read
604 {
605 my ( $self, $buffref, $eof ) = @_;
606
607 if( length $$buffref >= 16 ) {
608 my $record = substr( $$buffref, 0, 16, "" );
609 print "Received a 16-byte record: $record\n";
610
611 return 1;
612 }
613
614 if( $eof and length $$buffref ) {
615 print "EOF: a partial record still exists\n";
616 }
617
618 return 0;
619 }
620
621 This time, rather than a "while()" loop we have decided to have the
622 handler just process one record, and use the "return 1" mechanism to
623 ask that the handler be invoked again if there still remains data that
624 might contain another record; only stopping with "return 0" when we
625 know we can't find one.
626
627 The 4-argument form of "substr()" extracts the 16-byte record from the
628 buffer and assigns it to the $record variable, if there was enough data
629 in the buffer to extract it.
630
631 A lot of protocols use a fixed-size header, followed by a variable-
632 sized body of data, whose size is given by one of the fields of the
633 header. The following "on_read" method extracts messages in such a
634 protocol.
635
636 sub on_read
637 {
638 my ( $self, $buffref, $eof ) = @_;
639
640 return 0 unless length $$buffref >= 8; # "N n n" consumes 8 bytes
641
642 my ( $len, $x, $y ) = unpack "N n n", $$buffref;
643
644 return 0 unless length $$buffref >= 8 + $len;
645
646 substr( $$buffref, 0, 8, "" );
647 my $data = substr( $$buffref, 0, $len, "" );
648
649 print "A record with values x=$x y=$y\n";
650
651 return 1;
652 }
653
654 In this example, the header is "unpack()"ed first, to extract the body
655 length, and then the body is extracted. If the buffer does not have
656 enough data yet for a complete message then 0 is returned, and the
657 buffer is left unmodified for next time. Only when there are enough
658 bytes in total does it use "substr()" to remove them.
659
660 Dynamic replacement of "on_read"
661 Consider the following protocol (inspired by IMAP), which consists of
662 "\n"-terminated lines that may have an optional data block attached.
663 The presence of such a data block, as well as its size, is indicated by
664 the line prefix.
665
666 sub on_read
667 {
668 my $self = shift;
669 my ( $buffref, $eof ) = @_;
670
671 if( $$buffref =~ s/^DATA (\d+):(.*)\n// ) {
672 my $length = $1;
673 my $line = $2;
674
675 return sub {
676 my $self = shift;
677 my ( $buffref, $eof ) = @_;
678
679 return 0 unless length $$buffref >= $length;
680
681 # Take and remove the data from the buffer
682 my $data = substr( $$buffref, 0, $length, "" );
683
684 print "Received a line $line with some data ($data)\n";
685
686 return undef; # Restore the original method
687 }
688 }
689 elsif( $$buffref =~ s/^LINE:(.*)\n// ) {
690 my $line = $1;
691
692 print "Received a line $line with no data\n";
693
694 return 1;
695 }
696 else {
697 print STDERR "Unrecognised input\n";
698 # Handle it somehow
699 }
700 }
701
702 In the case where trailing data is supplied, a new temporary "on_read"
703 callback is provided in a closure. This closure captures the $length
704 variable so it knows how much data to expect. It also captures the
705 $line variable so it can use it in the event report. When this method
706 has finished reading the data, it reports the event, then restores the
707 original method by returning "undef".
708
710 ยท IO::Handle - Supply object methods for I/O handles
711
713 Paul Evans <leonerd@leonerd.org.uk>
714
715
716
717perl v5.28.0 2018-07-14 IO::Async::Stream(3)