#!/bin/Perl
#This is the server side
use strict;
use IO::Socket;
my $sock = new IO::Socket::INET (LocalPort => 1200,
Proto => 'tcp',
Listen => 5,
Reuse => 1);
die "Can't connect: $!\n" unless $sock;
while (my $new_sock = $sock->accept())
{
my $msg = <$new_sock>;
print "client said '$msg'\n";
}
close $sock;
#Client Side
use strict;
use IO::Socket;
my $sock = new IO::Socket::INET (PeerAddr => '127.0.0.1',
PeerPort => 1200,
Proto => 'tcp');
die "Can't create: $!\n" unless $sock;
print $sock "send money!";
close $sock;
####
for(my $i=0; $i <= 10; $i++)
{
print $sock "$i\n";
}
print $sock "**** End of transmission ****";
####
'0
'