#! perl -slw use strict; use IO::Socket::INET; use Net::Patricia; use Time::HiRes qw[ time ]; my $pat = Net::Patricia->new; open I, '<', 'IP-to-ASmapping.txt' or die $!; $pat->add_string( split ' ', $_ ) while ; close I; my $listener = IO::Socket::INET->new( LocalAddr => 'localhost:88888', Listen => 1000, Reuse => 1, ) or die "Couldn't listen on localhost:88888; $!"; my $time = time(); my $count = 0; while( my $client = $listener->accept ) { printf "\rRate: %7.3f\t", $count / ( time() -$time ) if ++$count % 100; chomp( my $ip = <$client> ); print { $client } $pat->match_string( $ip ) || 'n/a'; close $client; } __END__ C:\test>623661-s Rate: 108.149