Hi guys, can anyone help me. Im actually writing a script to distribute processing amoung 4 workstations.
The problem is that i have been having a problem sending and receiving data between sockets. For the time being im just trying it out on one workstation.
My server code is as follows:
#!/usr/bin/perl -w
use IO::Socket;
use Net::hostent;
foreach $argnum (0 .. $#ARGV) {
if ($ARGV[$argnum] eq "-s" {
$startframe = $ARGV[$argnum + 1];
}
if ($ARGV[$argnum] eq "-e" {
$endframe = $ARGV[$argnum + 1]; }
if ($ARGV[$argnum] eq "-proj" {
$projdir = $ARG[$argnum + 1] ; }
if ($ARGV[$argnum] eq "-rd" {
$renderdir = $ARG[$argnum + 1];
}
if ($ARGV[$argnum] = $#ARGV - 1){
$filename = $ARG[$argnum];
}
}
$PORT = 7700; # pick something not in use
$server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => $PORT,
Listen => SOMAXCONN,
Reuse => 1,
Type => SOCK_STREAM,
Family => AF_UNIX );
die "can't setup server" unless $server;
print "[Server $0 accepting clients]\n";
while ($client = $server->accept()) {
$client->autoflush(1);
print $client "Welcome to $0; Are you ready to Render \n";
$hostinfo = gethostbyaddr($client->peeraddr);
printf "\n[Connect from %s]\n", $hostinfo->name || $client->peerhost;
# $server->send($client, $startframe,18)
or die "Can't send: $!\n";
# THIS IS WHERE THE PROBLEM IS
printf "Sending Message $startframe";
# write ($client,$startframe,50);
# write ($client,$endframe,50);
close $client;
}
# My client code is as follows
#!/usr/bin/perl -w
use IO::Socket;
$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "localhost",
PeerPort => "7700",
)
or die "cannot connect to port at localhost";
$remote->autoflush(1);
while ( <$remote> ) {
read ($remote,$buf,18);
printf $remote "$buf \n";
# print
}
# print "This is the startframe ",$startframe;
kill("TERM",$remote);
The problem is that i have been having a problem sending and receiving data between sockets. For the time being im just trying it out on one workstation.
My server code is as follows:
#!/usr/bin/perl -w
use IO::Socket;
use Net::hostent;
foreach $argnum (0 .. $#ARGV) {
if ($ARGV[$argnum] eq "-s" {
$startframe = $ARGV[$argnum + 1];
}
if ($ARGV[$argnum] eq "-e" {
$endframe = $ARGV[$argnum + 1]; }
if ($ARGV[$argnum] eq "-proj" {
$projdir = $ARG[$argnum + 1] ; }
if ($ARGV[$argnum] eq "-rd" {
$renderdir = $ARG[$argnum + 1];
}
if ($ARGV[$argnum] = $#ARGV - 1){
$filename = $ARG[$argnum];
}
}
$PORT = 7700; # pick something not in use
$server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => $PORT,
Listen => SOMAXCONN,
Reuse => 1,
Type => SOCK_STREAM,
Family => AF_UNIX );
die "can't setup server" unless $server;
print "[Server $0 accepting clients]\n";
while ($client = $server->accept()) {
$client->autoflush(1);
print $client "Welcome to $0; Are you ready to Render \n";
$hostinfo = gethostbyaddr($client->peeraddr);
printf "\n[Connect from %s]\n", $hostinfo->name || $client->peerhost;
# $server->send($client, $startframe,18)
or die "Can't send: $!\n";
# THIS IS WHERE THE PROBLEM IS
printf "Sending Message $startframe";
# write ($client,$startframe,50);
# write ($client,$endframe,50);
close $client;
}
# My client code is as follows
#!/usr/bin/perl -w
use IO::Socket;
$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "localhost",
PeerPort => "7700",
)
or die "cannot connect to port at localhost";
$remote->autoflush(1);
while ( <$remote> ) {
read ($remote,$buf,18);
printf $remote "$buf \n";
}
# print "This is the startframe ",$startframe;
kill("TERM",$remote);