Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Getting website by "socket", program hangs

Reply
Thread Tools

Getting website by "socket", program hangs

 
 
Knut
Guest
Posts: n/a
 
      07-19-2004
Hey,

I'm building a small linkchecker ++ to do some maintanence on a
webserver I work with, but I have a problem.

At about check nr. 13, the program hangs when getting a website from
the web. (odin.dep.no/ud/norsk/aktuelt/taler/statsraad_b/032171-090195/index-dok000-b-n-a.html)

My procedure is as follows:

my $host="$_[0]";
my $getstring="GET http://$_[1] HTTP/1.0\n\n";
my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => 80,
Proto => 'tcp') or print "ERRROR!!!";
print $sock "$getstring";

my $buf="";
while($line = <$sock>) {
$buf.=$line;
}

This works for the first few sites, but then hangs. Nothing seems to
get read by the buffer at all...

Can someone please help?

Thanks in advance!

.. Knut
 
Reply With Quote
 
 
 
 
Tore Aursand
Guest
Posts: n/a
 
      07-19-2004
On Mon, 19 Jul 2004 03:33:45 -0700, Knut wrote:
> my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => 80,
> Proto => 'tcp') or print "ERRROR!!!";


Why use 'IO::Socket::INET' in the first place? Isn't LWP::UserAgent (or
it's derivates) adequate for your needs?


--
Tore Aursand <(E-Mail Removed)>
"Programming is like sex, one mistake and you have to support it for
the rest of your life." (Michael Sinz)
 
Reply With Quote
 
 
 
 
Scott W Gifford
Guest
Posts: n/a
 
      07-19-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Knut) writes:

[...]

> At about check nr. 13, the program hangs when getting a website from
> the web. (odin.dep.no/ud/norsk/aktuelt/taler/statsraad_b/032171-090195/index-dok000-b-n-a.html)
>
> My procedure is as follows:
>
> my $host="$_[0]";
> my $getstring="GET http://$_[1] HTTP/1.0\n\n";
> my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => 80,
> Proto => 'tcp') or print "ERRROR!!!";
> print $sock "$getstring";
>
> my $buf="";
> while($line = <$sock>) {
> $buf.=$line;
> }


The proper line ending for an HTTP request is \r\n, so it's possible
that one Web server doesn't recognized that you've finished sending
the command. In general you don't start the request with "http://"
either, but just send the path part of the request.

It's also possible that there's a DNS problem causing a very long
delay.

Adding some debug statements to tell you exactly where it is hanging
(during the connect? During the print? Waiting for the response?)
would be helpful too, and looking at a tcpdump while you're doing this
might be enlightening too. And changing the order of the sites, to
see if it's the fact that it's the 13th or the site itself, would also
give you useful information.

Good luck!

----ScottG.
 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      07-19-2004
Knut wrote:

> Hey,
>
> I'm building a small linkchecker ++ to do some maintanence on a
> webserver I work with, but I have a problem.
>
> At about check nr. 13, the program hangs when getting a website
>
> my $host="$_[0]";
> my $getstring="GET http://$_[1] HTTP/1.0\n\n";
> my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => 80,
> Proto => 'tcp') or print "ERRROR!!!";
> print $sock "$getstring";


It's not clear to me whether you are explicitly using an HTTP proxy
server or accidentally using a proxy server.

If $host is a server set up to be a proxy, then $getstring is ok.
If $host is the server and $_[1] is something like "/foo/index.html"
then you should not be putting "http://" in the GET string.
-Joe
 
Reply With Quote
 
Knut
Guest
Posts: n/a
 
      07-20-2004
It sure is... I just had no clue it exsisted

Thanks (to all), works perfectly now. (=

.. K


Tore Aursand <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>.. .
> On Mon, 19 Jul 2004 03:33:45 -0700, Knut wrote:
> > my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => 80,
> > Proto => 'tcp') or print "ERRROR!!!";

>
> Why use 'IO::Socket::INET' in the first place? Isn't LWP::UserAgent (or
> it's derivates) adequate for your needs?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gem hangs => TCPSocket.write hangs Tim Shadel Ruby 1 07-24-2005 06:11 AM
Max number of operations? (Good WAVE converter program hangs with "long" input files) Alex Ochoa Java 4 01-18-2005 03:30 PM
Getting rid of program loaded from website Leon Kyneur Computer Security 11 09-02-2004 02:55 AM
Clear hangs up - & hangs up - & hangs up Sue Bilstein NZ Computing 26 03-07-2004 01:33 AM
Java program hangs on new PrintWriter Oz Levanon Java 1 03-01-2004 01:44 AM



Advertisments