Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

vortx.pl (See related posts)

#!/usr/bin/perl -w
# 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: $!";

You need to create an account or log in to post comments to this site.


Click here to browse all 4834 code snippets

Related Posts