|
NAMEMojo::IOLoop::Client - Non-blocking TCP/IP and UNIX domain socket client SYNOPSIS use Mojo::IOLoop::Client;
# Create socket connection
my $client = Mojo::IOLoop::Client->new;
$client->on(connect => sub ($client, $handle) {...});
$client->on(error => sub ($client, $err) {...});
$client->connect(address => 'example.com', port => 80);
# Start reactor if necessary
$client->reactor->start unless $client->reactor->is_running;
DESCRIPTIONMojo::IOLoop::Client opens TCP/IP and UNIX domain socket connections for Mojo::IOLoop. EVENTSMojo::IOLoop::Client inherits all events from Mojo::EventEmitter and can emit the following new ones. connect $client->on(connect => sub ($client, $handle) {...});
Emitted once the connection is established. error $client->on(error => sub ($client, $err) {...});
Emitted if an error occurs on the connection, fatal if unhandled. ATTRIBUTESMojo::IOLoop::Client implements the following attributes. reactormy $reactor = $client->reactor; $client = $client->reactor(Mojo::Reactor::Poll->new); Low-level event reactor, defaults to the "reactor" attribute value of the global Mojo::IOLoop singleton. Note that this attribute is weakened. METHODSMojo::IOLoop::Client inherits all methods from Mojo::EventEmitter and implements the following new ones. can_nnrmy $bool = Mojo::IOLoop::Client->can_nnr; True if Net::DNS::Native 0.15+ is installed and non-blocking name resolution support enabled. can_socksmy $bool = Mojo::IOLoop::Client->can_socks; True if IO::Socket::SOCKS 0.64+ is installed and SOCKS5 support enabled. connect $client->connect(address => '127.0.0.1', port => 3000);
$client->connect({address => '127.0.0.1', port => 3000});
Open a socket connection to a remote host. Note that non-blocking name resolution depends on Net::DNS::Native (0.15+), SOCKS5 support on IO::Socket::Socks (0.64), and TLS support on IO::Socket::SSL (2.009+). These options are currently available:
SEE ALSOMojolicious, Mojolicious::Guides, <https://mojolicious.org>.
|