#!/usr/bin/perl
use strict;
use warnings;
use Socket;

my $port = 9999;
my $host = "localhost";

my $socket;
my $iaddr = inet_aton($host);
my $paddr = sockaddr_in($port, $iaddr);

socket($socket, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
connect($socket, $paddr) or die $!;

my $line;
while ($line = <$socket>){
    print "$line\n";
}
close $socket or die "close : $!";

exit(0);