NAME

Reflex::Listener - Generate connected client sockets from a listening server socket.

VERSION

version 0.010

SYNOPSIS

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

DESCRIPTION

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.

Attributes

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.

Methods

Reflex::Listener inherits its methods from Reflex::Handle. It doesn't add new methods at this time.

EXAMPLES

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.

SEE ALSO

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