The Client Program : Client « Network « Perl






The Client Program

    


#!/usr/bin/perl

print "client\n";

$AF_UNIX=1;
$SOCK_STREAM=1;
$PROTOCOL=0;

socket(CLIENTSOCKET, $AF_UNIX, $SOCK_STREAM, $PROTOCOL);
$name="./greetings";

do{
   $result = connect(CLIENTSOCKET, "$name" );
   if ($result != 1 ){
      sleep(1);
   }
}while($result !=  1 ); # Loop until a connection is made

read(CLIENTSOCKET, $buf, 500);
print STDOUT "$buf\n";
close (CLIENTSOCKET);
exit(0);

   
    
    
    
  








Related examples in the same category

1.Time client
2.Two way client
3.The Client with Socket
4.A Daytime Client
5.Read the first line from a remote server