LJ Archive CD

Listing 4. clientIO.pl

#!/usr/bin/perl -w
# clientIO.pl - a simple client using
# IO::Socket
use strict;
use IO::Socket;
my $host = shift || 'server.onsight.com';
my $port = shift || 7890;
my $sock = new IO::Socket::INET(
                   PeerAddr => $host,
                   PeerPort => $port,
                   Proto    => 'tcp');
$sock or die "no socket :$!";
foreach my $i (1..10) {
    print $sock "hello, world: $i\n";
}
close $sock;

LJ Archive CD