<?xml version="1.0" encoding="windows-1252"?>
<node id="993921" title="Timeout for connect in Anyevent::HTTP. Help, please." created="2012-09-16 11:24:40" updated="2012-09-16 11:24:40">
<type id="115">
perlquestion</type>
<author id="970897">
0day</author>
<data>
<field name="doctext">
I can not figure out where and what code I have to insert, to set the time to make a connection.
&lt;code&gt;
use AnyEvent::HTTP;

http_request GET =&gt; "$url", headers =&gt; {
   'Host' =&gt; $host,
   'Connection' =&gt; 'keep-alive',
   'User-Agent' =&gt; 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.8 (KHTML, like Gecko) Chrome/20.0.1108.0 Safari/536.8',
   'Content-Type' =&gt; 'application/x-www-form-urlencoded',
   'Referer' =&gt; $host
  },
  tcp_connect =&gt; sub {
    my ($host, $service, $connect_cb, $prepare_cb) = @_;
    tcp_connect $ip, $service, sub { 
          $connect_cb-&gt;(@_); 
    }, sub {
          $prepare_cb-&gt;(@_);
    };
  },
  sub {
   #my ($body, $hdr) = @_;
    callback ($_[0], $_[1], $ip, $host, undef, undef, undef, $error_count, $redirect);
    $cv-&gt;end;
  }; 
&lt;/code&gt;</field>
</data>
</node>
