#!c:/perl/bin/perl -w $|++; use strict; use IO::Socket::INET; # Initialize the server my $sock = new IO::Socket::INET ( LocalHost => '127.0.0.1', LocalPort => '7070', Proto => 'tcp', Listen => 1, ReuseAddr => 1 ) or die "Server could not initialize!\n\n"; # Autoflush for verisons before 1.18 $sock->autoflush(1); print "The server has successfully initialized.\n\n"; # Allow another client to connect after the # current client disconnects from the server. while ( my $new_sock = $sock->accept() ) { print "A client has connected to the server.\n"; # Example output to the client for my $i (1 .. 5) { sleep 1; print $new_sock $i, "\n"; } close $new_sock; }