2011-05-02 10:53:52 +04:00
|
|
|
/*
|
|
|
|
* ClientSideProc.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <memory.h> /* for memset */
|
|
|
|
#include "square.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <rpc/pmap_clnt.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <memory.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
CLIENT *cl;
|
2011-05-02 12:11:12 +04:00
|
|
|
square_in in;
|
|
|
|
square_out out;
|
2011-05-02 10:53:52 +04:00
|
|
|
if (argc != 3) {
|
|
|
|
printf("Usage : client <hostname> <integer_valus=e>\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
cl = clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, "tcp");
|
|
|
|
if (cl == NULL) {
|
|
|
|
clnt_perror(cl, "call failed");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
in.arg1 = atol(argv[2]);
|
|
|
|
if (squareproc_2(&in, &out, cl) != RPC_SUCCESS) {
|
2011-05-02 12:23:17 +04:00
|
|
|
clnt_perror(cl, argv[1]);
|
|
|
|
//printf("%s\n", clnt_perror(cl, argv[1]));
|
2011-05-02 10:53:52 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
printf("result: %ld\n", out.res1);
|
|
|
|
exit(0);
|
|
|
|
}
|