How to set the server timeout limit ?

A Webget Client

#!/usr/bin/perl -w
    use IO::Socket;
    unless (@ARGV > 1) { die "usage: $0 host document ..." }
    $host = shift(@ARGV);
    $EOL = "\015\012";
    $BLANK = $EOL x 2;
    foreach $document ( @ARGV ) {
        $remote = IO::Socket::INET->new( Proto     => "tcp",
                                         PeerAddr  => $host,
                                         PeerPort  => "http(80)",
                                        );
        unless ($remote) { die "cannot connect to http daemon on $host" }
        $remote->autoflush(1);
        print $remote "GET $document HTTP/1.0" . $BLANK;
        while ( <$remote> ) { print }
        close $remote;
    }


Using the above script I can get html documents ...


BUt suppose the document is say 2 MB and there is a server timeout . I dont want the script to wait endlessly..

I want to set the timeout of the GET request .. is it possible ..

The script should request the document and if it is not getting the document within the SET timeout it should come back from the routine

help

BTW using the above routine I am able to access

"www.yahoo.com" type of addressess but Im
NOT able to retrieve

"username.hypermart.net" kind of documents

is there a solution ?



chris

LVL 6
christopher sagayamAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jhurstConnect With a Mentor Commented:
to get username.hypermart.net add
print $remote "Host: username.hypermart.net" . $BLANK
and change the GET to use $EOL not BLANK

Hypermart uses virtual hosting and so use the HTTP_HOST to determine where you really need to go.
0
 
ozoCommented:
$remote = IO::Socket::INET->new( Proto     => "tcp",
                                 PeerAddr  => $host,
                                 PeerPort  => "http(80)",
                                 Timeout   => $timeout.
                                );
$remote->timeout($timeout);
0
 
christopher sagayamAuthor Commented:
thanks for answering the first question

Is there a chance I can expect an answer for the second too ?

chris
0
 
christopher sagayamAuthor Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.