Reflex::Listener - Generate connected client sockets from a listening server socket.
version 0.011
# This is an incomplete excerpt from eg/eg-34-tcp-server-echo.pl. package TcpEchoServer; use Moose; extends 'Reflex::Listener'; use Reflex::Collection; use EchoStream; has clients => ( is => 'rw', isa => 'Reflex::Collection', default => sub { Reflex::Collection->new() }, handles => { remember_client => "remember" }, ); sub on_listener_accepted { my ($self, $args) = @_; $self->remember_client( EchoStream->new( handle => $args->{socket}, rd => 1, ) ); } sub on_listener_failure { my ($self, $args) = @_; warn "$args->{errfun} error $args->{errnum}: $args->{errstr}\n"; }
Reflex::Listener extends Reflex::Handle. It watches listening server sockets for new client connections. When they arrive, it accept()s them and emits them in "accepted" events.
Reflex::Listener inherits its attributes from Reflex::Handle. It sets the rd() attribute to true by default---so listeners start up ready to accept connections.
Reflex::Listener inherits its methods from Reflex::Handle. It doesn't add new methods at this time.
eg/eg-34-tcp-server-echo.pl in Reflex's distribution implements a simple TCP server using Reflex::Listener. The SYNOPSIS for this module is an excerpt from that example.
Reflex Reflex::Handle
"ACKNOWLEDGEMENTS" in Reflex "ASSISTANCE" in Reflex "AUTHORS" in Reflex "BUGS" in Reflex "BUGS" in Reflex "CONTRIBUTORS" in Reflex "COPYRIGHT" in Reflex "LICENSE" in Reflex "TODO" in Reflex
To install Reflex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Reflex
CPAN shell
perl -MCPAN -e shell install Reflex
For more information on module installation, please visit the detailed CPAN module installation guide.