Skip to content

Instantly share code, notes, and snippets.

@othtim
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save othtim/8798088 to your computer and use it in GitHub Desktop.

Select an option

Save othtim/8798088 to your computer and use it in GitHub Desktop.
GET a url continually
# dont point this at anyone
use IO::Socket;
use strict;
my ($hash, $result);
my $i = 1;
my $line;
my $data;
$data = "GET / HTTP/1.1\nHost: www.google.com\n";
while(1){
$hash->{$i} = new IO::Socket::INET (
PeerAddr => '127.0.0.1',
PeerPort => '80',
Proto => 'tcp',
Timeout => 1,
Blocking => 0
) or die "ERROR in Socket Creation : $!\n";
$hash->{$i}->autoflush(1);
#print "TCP Connection Success.\n";
$result = $hash->{$i};
print $result "$data\n";
while($line = <$result>){
print $line . "\n";
}
$hash->{$i}->close();
$i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment