Reflex::Client - A non-blocking socket client.
version 0.010
This is a complete working TCP echo client. It's the version of eg/eg-35-tcp-client.pl available at the time of this writing.
use lib qw(../lib); { package TcpEchoClient; use Moose; extends 'Reflex::Client'; sub on_client_connected { my ($self, $args) = @_; $self->connection()->put("Hello, world!\n"); }; sub on_client_data { my ($self, $args) = @_; # Not chomped. warn "got from server: $args->{data}"; # Disconnect after we receive the echo. $self->stop(); } } TcpEchoClient->new( remote_addr => '127.0.0.1', remote_port => 12345, )->run_all();
Reflex::Client is a high-level base class for non-blocking socket clients. As with other Reflex::Object classes, this one may be subclassed, composed with "has", or driven with condvar-like syntax.
Reflex::Client extends (and includes the attributes of) Reflex::Connector, which extends Reflex::Handle. It also provides its own attributes.
The "protocol" attribute contains the name of a class that will handle I/O for the client. It contains "Reflex::Stream" by default.
Protocol classes should extend Reflex::Stream or at least follow its interface.
Reflex::Client extends Reflex::Handle, but it currently provides no additional methods.
Reflex::Client emits some of its own high-level events based on its components' activities.
Reflex::Client emits "connected" to notify consumers when the client has connected, and it's safe to begin sending data.
Reflex::Client emits stream data with the "data" event. This event is provided by Reflex::Stream. Please see "data" in Reflex::Stream for the most current documentation.
eg/eg-35-tcp-client.pl subclasses Reflex::Client as TcpEchoClient.
Reflex Reflex::Client
"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.