specifying timeout in GET request ?????????

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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jhurstCommented:
There is no timeout that you can set in the http-header when you make the request.  The spec is on line at:  www.w3.org.

As to the user.hypermart.net problem.  This is because they are using virtual hosting and require that the http_host be set.  You can do this by adding a:

print "Host: user.hypermart.net" . $BLANK;

and changing the $BLANK to an $EOL in the GET line.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
christopher sagayamAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.