perl实例之简单客户端程序。
代码:
#!/usr/bin/perl
#
print "clientn";
$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 "$bufn";
close (CLIENTSOCKET);
exit(0);