Listing A


use IO::Socket;
 


my ($server, $client);
 

$server = IO::Socket::INET->new(

       Proto     => 'tcp',

       LocalPort => 80,        # HTTP's standard port

       Listen    => SOMAXCONN,

       Reuse     => 1

       );

$server or die "can't setup server";

 
print "--- Accepting Port requests ---\n";

 
while ($client = $server->accept())

{

       printf "--- New Connection begins ---\n";

       $client->autoflush(1);

       while ( <$client> ) { print; }

       close $client;

}