.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mojo::IOLoop::Client 3pm" .TH Mojo::IOLoop::Client 3pm "2019-02-05" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojo::IOLoop::Client \- Non\-blocking TCP/IP and UNIX domain socket client .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mojo::IOLoop::Client; \& \& # Create socket connection \& my $client = Mojo::IOLoop::Client\->new; \& $client\->on(connect => sub { \& my ($client, $handle) = @_; \& ... \& }); \& $client\->on(error => sub { \& my ($client, $err) = @_; \& ... \& }); \& $client\->connect(address => \*(Aqexample.com\*(Aq, port => 80); \& \& # Start reactor if necessary \& $client\->reactor\->start unless $client\->reactor\->is_running; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mojo::IOLoop::Client opens \s-1TCP/IP\s0 and \s-1UNIX\s0 domain socket connections for Mojo::IOLoop. .SH "EVENTS" .IX Header "EVENTS" Mojo::IOLoop::Client inherits all events from Mojo::EventEmitter and can emit the following new ones. .SS "connect" .IX Subsection "connect" .Vb 4 \& $client\->on(connect => sub { \& my ($client, $handle) = @_; \& ... \& }); .Ve .PP Emitted once the connection is established. .SS "error" .IX Subsection "error" .Vb 4 \& $client\->on(error => sub { \& my ($client, $err) = @_; \& ... \& }); .Ve .PP Emitted if an error occurs on the connection, fatal if unhandled. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Mojo::IOLoop::Client implements the following attributes. .SS "reactor" .IX Subsection "reactor" .Vb 2 \& my $reactor = $client\->reactor; \& $client = $client\->reactor(Mojo::Reactor::Poll\->new); .Ve .PP Low-level event reactor, defaults to the \f(CW\*(C`reactor\*(C'\fR attribute value of the global Mojo::IOLoop singleton. Note that this attribute is weakened. .SH "METHODS" .IX Header "METHODS" Mojo::IOLoop::Client inherits all methods from Mojo::EventEmitter and implements the following new ones. .SS "can_nnr" .IX Subsection "can_nnr" .Vb 1 \& my $bool = Mojo::IOLoop::Client\->can_nnr; .Ve .PP True if Net::DNS::Native 0.15+ is installed and non-blocking name resolution support enabled. .SS "can_socks" .IX Subsection "can_socks" .Vb 1 \& my $bool = Mojo::IOLoop::Client\->can_socks; .Ve .PP True if IO::Socket::SOCKS 0.64+ is installed and \s-1SOCKS5\s0 support enabled. .SS "connect" .IX Subsection "connect" .Vb 2 \& $client\->connect(address => \*(Aq127.0.0.1\*(Aq, port => 3000); \& $client\->connect({address => \*(Aq127.0.0.1\*(Aq, port => 3000}); .Ve .PP Open a socket connection to a remote host. Note that non-blocking name resolution depends on Net::DNS::Native (0.15+), \s-1SOCKS5\s0 support on IO::Socket::Socks (0.64), and \s-1TLS\s0 support on IO::Socket::SSL (2.009+). .PP These options are currently available: .IP "address" 2 .IX Item "address" .Vb 1 \& address => \*(Aqmojolicious.org\*(Aq .Ve .Sp Address or host name of the peer to connect to, defaults to \f(CW127.0.0.1\fR. .IP "handle" 2 .IX Item "handle" .Vb 1 \& handle => $handle .Ve .Sp Use an already prepared IO::Socket::IP object. .IP "local_address" 2 .IX Item "local_address" .Vb 1 \& local_address => \*(Aq127.0.0.1\*(Aq .Ve .Sp Local address to bind to. .IP "path" 2 .IX Item "path" .Vb 1 \& path => \*(Aq/tmp/myapp.sock\*(Aq .Ve .Sp Path of \s-1UNIX\s0 domain socket to connect to. .IP "port" 2 .IX Item "port" .Vb 1 \& port => 80 .Ve .Sp Port to connect to, defaults to \f(CW80\fR or \f(CW443\fR with \f(CW\*(C`tls\*(C'\fR option. .IP "socks_address" 2 .IX Item "socks_address" .Vb 1 \& socks_address => \*(Aq127.0.0.1\*(Aq .Ve .Sp Address or host name of \s-1SOCKS5\s0 proxy server to use for connection. .IP "socks_pass" 2 .IX Item "socks_pass" .Vb 1 \& socks_pass => \*(Aqsecr3t\*(Aq .Ve .Sp Password to use for \s-1SOCKS5\s0 authentication. .IP "socks_port" 2 .IX Item "socks_port" .Vb 1 \& socks_port => 9050 .Ve .Sp Port of \s-1SOCKS5\s0 proxy server to use for connection. .IP "socks_user" 2 .IX Item "socks_user" .Vb 1 \& socks_user => \*(Aqsri\*(Aq .Ve .Sp Username to use for \s-1SOCKS5\s0 authentication. .IP "timeout" 2 .IX Item "timeout" .Vb 1 \& timeout => 15 .Ve .Sp Maximum amount of time in seconds establishing connection may take before getting canceled, defaults to \f(CW10\fR. .IP "tls" 2 .IX Item "tls" .Vb 1 \& tls => 1 .Ve .Sp Enable \s-1TLS.\s0 .IP "tls_ca" 2 .IX Item "tls_ca" .Vb 1 \& tls_ca => \*(Aq/etc/tls/ca.crt\*(Aq .Ve .Sp Path to \s-1TLS\s0 certificate authority file. .IP "tls_cert" 2 .IX Item "tls_cert" .Vb 1 \& tls_cert => \*(Aq/etc/tls/client.crt\*(Aq .Ve .Sp Path to the \s-1TLS\s0 certificate file. .IP "tls_key" 2 .IX Item "tls_key" .Vb 1 \& tls_key => \*(Aq/etc/tls/client.key\*(Aq .Ve .Sp Path to the \s-1TLS\s0 key file. .IP "tls_protocols" 2 .IX Item "tls_protocols" .Vb 1 \& tls_protocols => [\*(Aqfoo\*(Aq, \*(Aqbar\*(Aq] .Ve .Sp \&\s-1ALPN\s0 protocols to negotiate. .IP "tls_verify" 2 .IX Item "tls_verify" .Vb 1 \& tls_verify => 0x00 .Ve .Sp \&\s-1TLS\s0 verification mode. .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .