Using perl Syntax Highlighting
#!/usr/bin/perl
# getservertype2.pl - a forking version
use IO::Socket;
use strict;
use warnings;
$|=1;
my $sitio = '127.0.0.1';
my $n = 5;
my @hosts = map { $sitio } 1 .. $n;
print "Iniciando...\n";
sub doit {
my $server = shift;
print "Conectado al $server\n";
my $sock
= new IO::Socket::INET(
PeerAddr => $server,
PeerPort => 80,
Proto => 'tcp',
)
or die "$!\n"
;
print $sock "Prueba";
while ( <$sock> ) {
if (/^Server:\s*(.*)/) {
print "$server: $1\n";
last;
}
}
}
for ( @hosts ) {
next if my $kid = fork; # el padre sigue
die "fork: $!" unless defined $kid;
doit $_;
exit; # el hijo muere
}
"muerte!" while wait != -1; # esperamos a todos los muertos
print "Terminado.\n";
# getservertype2.pl - a forking version
use IO::Socket;
use strict;
use warnings;
$|=1;
my $sitio = '127.0.0.1';
my $n = 5;
my @hosts = map { $sitio } 1 .. $n;
print "Iniciando...\n";
sub doit {
my $server = shift;
print "Conectado al $server\n";
my $sock
= new IO::Socket::INET(
PeerAddr => $server,
PeerPort => 80,
Proto => 'tcp',
)
or die "$!\n"
;
print $sock "Prueba";
while ( <$sock> ) {
if (/^Server:\s*(.*)/) {
print "$server: $1\n";
last;
}
}
}
for ( @hosts ) {
next if my $kid = fork; # el padre sigue
die "fork: $!" unless defined $kid;
doit $_;
exit; # el hijo muere
}
"muerte!" while wait != -1; # esperamos a todos los muertos
print "Terminado.\n";
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4