in reply to Re^2: Timeout for an established connection
in thread Timeout for an established connection

Okay, that explains the problem you are trying to deal with. Ie: when a server accepts a request ($svr->send( GET ... )), but never actually responds.

By default, the connection will remain open for something like 900 seconds. The solution is to use setsockopt() to set the TCP_USER_TIMEOUT.

A search for that term will turn up the relevant docs.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Timeout for an established connection
by 0day (Sexton) on Jan 01, 2013 at 22:20 UTC
    Thanks... but, unfortunately I did not find this flag in perl modules.
      I did not find this flag in perl modules.

      Look up the appropriate numeric value in your C-runtime header files and use that.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Dear BrowserUk, thank you for your reply.
        Please tell me what to do if the call setsokopt
        setsockopt($sock, 6, 18, pack("QQ", 5, 0)) or die "setsockopt SOL_TCP, TCP_USER_TIMEOUT: $!\n";
        returns an error "protocol not available"?
        Some more code:
        socket (my $sock, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die +"socket: $!"; if(fcntl ($sock, F_SETFL, O_NONBLOCK)){ my $iaddr = inet_aton(${$sock}->{host}) or return; my $paddr = sockaddr_in( ${$sock}->{port}, $iaddr ) or return; setsockopt($sock, SOL_SOCKET, SO_SNDTIMEO, pack("QQ", ${$sock}->{t +imeout}, 0)) or die "setsockopt SOL_SOCKET, SO_SNDTIMEO: $!\n"; setsockopt($sock, SOL_SOCKET, SO_RCVTIMEO, pack("QQ", ${$sock}->{t +imeout}, 0)) or die "setsockopt SOL_SOCKET, SO_RCVTIMEO: $!\n"; setsockopt($sock, 6, 18, pack("QQ", 5, 0)) or die "setsockopt SOL_ +TCP, TCP USER TIMEOUT: $!\n";
        To zentara. I want to give you some advice.
        1. read carefully the question.
        2. dump from this topic.
        Thank you.