Last active
August 29, 2015 13:56
-
-
Save othtim/8798088 to your computer and use it in GitHub Desktop.
GET a url continually
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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