Reflex::Connector - non-blocking client socket connector
version 0.060
This is a partial excerpt from eg/eg-38-promise-client.pl
use Reflex::Connector; use Reflex::Stream; my $connector = Reflex::Connector->new(port => 12345); my $event = $connector->next(); if ($event->{name} eq "failure") { die("error $event->{arg}{errnum}: $event->{arg}{errstr}"); } my $stream = Reflex::Stream->new( handle => $event->{arg}{socket}, );
Reflex::Connector asynchronously establishes a client connection. It is almost entirely implemented in Reflex::Role::Connecting. That role's documentation contains important details that won't be covered here.
address defines the remote address to which Reflex::Connector will attempt a connection. It defaults to "127.0.0.1". See Reflex::Role::Connecting for more details.
address
port defines the remote port to which Reflex::Connector will attempt a connection. It has no default. See Reflex::Role::Connecting for more details.
port
Reflex::Connector will provide its own socket by default. It also accepts a socket that may be configured in custom ways.
socket
See connector in Reflex::Role::Connecting for more details.
connector
None.
on_connection is called when Reflex::Connector establishes a connection. Reflex::Role::Connecting explains the data returned with on_connection. If necessary, that role will also define a default on_connection handler that emits "success" event. (TODO - Does this make sense?)
on_connection
on_error is called whenever a connection fails for some reason. returns an error. Reflex::Role::Connecting explains the data returned with on_error. If necessary, that role will also define a default on_error handler that emits an "error" event.
on_error
Reflex::Connector emits events related to establishing clinet connections. These events are defined by Reflex::Role::Connecting, and they will be explained there.
If no on_connection handler is set, then Reflex::Connector will emit a "success" event if the connection is successfuly established. Reflex::Role::Connecting explains this event in more detail.
If no on_error handler is set, then Reflex::Connector will emit an "error" event whenever a connection fails to establish. Reflex::Role::Connecting explains this event in more detail.
The SYNOPSIS is a partial excerpt from eg/eg-38-promise-client.pl
eg/eg-35-tcp-client.pl is a more callbacky client.
Reflex Reflex::Role::Connecting Reflex::Role::Accepting Reflex::Acceptor
"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.