#!/usr/bin/perl #client use strict; use warnings; use IO::Socket; #To flush the buffer print statements $| = 1; my $sock = new IO::Socket::INET( PeerAddr => 'localhost', PeerPort => 7890, Proto => 'tcp'); if ($sock) { print "A tcp socket on localhost connected to 7890\n"; } else { die "Error: $!"; } my $buf = "1234567890"; $sock->say($buf); print "Sent '$buf'\n"; $buf = $sock->getline(); chomp($buf); print "Bytes 10 = '$buf'\n"; $sock->say("1"); $buf = $sock->getline(); chomp($buf); print "Bytes 2 = '$buf'\n";