in reply to Downloading first X bytes of a file
#!/usr/bin/perl -w use strict; use IO::Socket::INET; my $sock = IO::Socket::INET->new(PeerAddr => 'www.google.de', PeerPort => 'http(80)', Proto => 'tcp'); die if ( !$sock ); print $sock "GET http://www.google.de/index.html\n"; my $len = 0; my $file = ''; while ( defined($sock) && ( my $c = $sock->getc()) && ($len<512)){ print $c,"\n\n"; $len+=length $c; $file .= $c; } print $file;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Downloading first X bytes of a file
by moritz (Cardinal) on Jun 09, 2008 at 12:09 UTC | |
by misc (Friar) on Jun 09, 2008 at 13:00 UTC | |
|
Re^2: Downloading first X bytes of a file
by tachyon-II (Chaplain) on Jun 09, 2008 at 15:27 UTC | |
by misc (Friar) on Jun 09, 2008 at 18:36 UTC | |
by misc (Friar) on Jun 09, 2008 at 18:35 UTC |