#!/usr/bin/perl -w
# Simple TCP socket client using IO::Socket

use strict;
use IO::Socket;

my $host = $ARGV[0] || 'localhost';
my $port = $ARGV[1] || 1337;

my $sock = new IO::Socket::INET (	PeerAddr	=>	$host,
					PeerPort	=>	$port,
					Proto		=>	'tcp',
			        );
die "Socket could not be created: $!\n" unless $sock;

while (<STDIN>) {
	print $sock $_;
}

#foreach (1..10) {
#	print $sock "Msg $_: How are you?\n";
#	$sock->flush();
#}
close ($sock);
