<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/tools/perl5.005/bin/perl

print "\n\n\t\t Usage CliIn.pl [server_host_name]\n";

print "\nHello I am Client\n";
($Dest)=@ARGV;
$Dest='hostname' unless $Dest;
print "Desination ---&gt; $Dest\n";
$port=9876; #Server is at this Port
$AF_INET=2;
$SOCK_STREAM=1;
$sockaddr='S n a4 x8';
($name,$ali,$proto)=getprotobyname('tcp');
if($port!~/^\d+$/) {
                   ($name,$ali,$port,$proto)=getservbyname($port,'tcp');
                  }
print "Port is $port\n";
($name,$ali,$type,$len,$Addr)=gethostbyname($Dest);
$Address=pack($sockaddr,$AF_INET,$port,$Addr);

print"$Address\n";

#Make the Socket File Handle

socket(CLIENTSOCKET,$AF_INET,$SOCK_STREAM,$porot) ||

die "Socket $!\n";
print "Socket is Created\n";

do{
   $result=connect(CLIENTSOCKET,"$Address");
   if($result!=1)
      {
       sleep(2);
      }
   }while($result!=1);
read(CLIENTSOCKET,$buf,500);
print STDOUT "\nThe Message Received $buf\n";
my @num=marshal($buf);
my $result=Add(@num);
print "\t### The Sum is $result\n\n";
close(CLIENTSOCKET);
exit(0);

sub marshal
  {
  my $param=shift;
  @numbers=split(",",$param);
  return(@numbers);
  }
sub Add
 {
 my @param=@_;
 my $i;
 my $sum=0;
 for ($i=0;$i&lt;=$#param;$i++)
  {
   $sum=$sum+$param[$i];
  }
 return($sum);
}
   
</pre></body></html>