NAME
Reflex::Connector - non-blocking client socket connector
VERSION
version 0.060
SYNOPSIS
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},
);
DESCRIPTION
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.
Public Attributes
address
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.
port
port
defines the remote port to which Reflex::Connector will attempt a connection. It has no default. See Reflex::Role::Connecting for more details.
socket
Reflex::Connector will provide its own socket by default. It also accepts a socket
that may be configured in custom ways.
See connector
in Reflex::Role::Connecting for more details.
Public Methods
None.
Callbacks
on_connection
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_error
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.
Public Events
Reflex::Connector emits events related to establishing clinet connections. These events are defined by Reflex::Role::Connecting, and they will be explained there.
success
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.
error
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.
EXAMPLES
The SYNOPSIS is a partial excerpt from eg/eg-38-promise-client.pl
eg/eg-35-tcp-client.pl is a more callbacky client.
SEE ALSO
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