if scan() contains print "$net.$hosts[$li]"; it executes perfectly, printing out all the ip's with no newlines or anything. but let's say this is scan:use IO::Socket; my $first_var = "64.219.21.1"; my $last_var = "25"; my ($net,$first) = ($first_var =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3})\.(\d +{1,3})$/ ); die "undetermined network part in $first_var.\n" unless $net; die "undetermined host part in $first_var.\n" unless $first; my ($last) = ($last_var =~ /^(\d{1,3})$/ ); die "undetermined host part in $last_var.\n" unless $last; ($last, $first) = ($first, $last) if $last < $first; my @hosts = ($first..$last); for ($li=0;$li<=$#hosts;$li++){ &scan() }
this gives an unknown error. i tried replacing $host with the url "feartech.net" it performed perfectly. so i suppose my question is, how to express the ip in a manner that the connection will go through. thanks for your help.sub scan { $host = "$net.$hosts[$li]"; $socket = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => 80) or die $!; $socket->autoflush(1); print $socket "HEAD / HTTP/1.0\015\012\015\012"; while (<$socket>) { print; last if /^$/; } close($socket); }
In reply to socket problems by common
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |