in reply to Re^4: Fetching HTML Pages with Sockets
in thread Fetching HTML Pages with Sockets
New error message is Connection reset by peer at ./pcs.pl line 29.use Socket; use CGI; my $page = connect_host() or die "$!";; print "$page"; flush(SOCK); sub connect_host { my $remote = gethostbyname("football.fantasysports.yahoo.com") +; my $proto = getprotobyname('tcp'); my $port = 80; my $remote_host = sockaddr_in($port,$remote); socket(SOCK,PF_INET,SOCK_STREAM,$proto) or die "$!"; connect(SOCK, $remote_host); print SOCK "GET / HTTP/1.0\015\012\015\012"; my $html = <SOCK> if(defined(<SOCK>)) or die "$!"; return $html; } sub flush { select($_[0]); my $t=$|; $|=1; $|=$t; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Fetching HTML Pages with Sockets
by ikegami (Patriarch) on Sep 19, 2004 at 20:51 UTC |