With the listed code, the program will only read one line from the client when it connects,
and then it will disconnect from the client.
You might want to do something like this:
$server = IO::Socket::INET->new
(
LocalPort => 1116,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 5
) or die "Could not open port.\n";
while ($client = $server->accept())
{
#
# start a new process for each new connection
#
my $pid = fork;
if( $pid < 0){
die "fork error: $!";
}elsif( $pid == 0){
#
# child process
# do whatever you want with the connection here
#
while( my $line = <$client>){
print $line;
}
close($client);
}
#
# parent falls through to listen for new connections
#
}
# should never reach here
#close( $server);
This lets you do whatever processing you want with the client, while still
accepting new client connections.