# Vortex0.pl
#----------------
use strict;
use Socket;
# initialize host and port
my $host = shift || 'localhost';
my $port = shift || 5842;
my $server = "vortex.labs.pulltheplug.org";
# create the socket, connect to the port
socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2])
or die "Can't create a socket $!\n";
connect( SOCKET, pack( 'Sn4x8', AF_INET, $port, $server ))
or die "Can't connect to port $port! \n";
my $comm;
while($comm=<STDIN>)
{
chomp $comm;
if($comm ne '')
{
print "\n Received 4-Byte Password '", $pass,"'\n";
$SOCKET->recv($pass,4);
print "\n Sending message '",$pass,"'";
if($SOCKET->send($pass))
{
print "[Done] CONGRATS! Time for some Vodka","\n";
}
}
else
{
# Send an empty message to server and exit
$SOCKET->send($pass);
exit 1;
}
}
close SOCKET or die "close: $!";