mstrelan
asked on
c pass string parameter with rpcgen
Hi,
I am wanting to create a basic c program using RPCGEN on the hello.x file below. How do I write my client file to pass the string parameter of print_hello to the server? I can easily pass a void parameter and return a string but not sure how to pass the string.
Cheers
I am wanting to create a basic c program using RPCGEN on the hello.x file below. How do I write my client file to pass the string parameter of print_hello to the server? I can easily pass a void parameter and return a string but not sure how to pass the string.
Cheers
---------- hello.x -------------------
program DISPLAY_PRG {
version DISPLAY_VER {
string print_hello( string ) = 1;
} = 1;
} = 0x20000001;
----------- hello_client.c ---------------
/*
The CLIENT program: hello_client.c
This will be the client code executed by the local client process.
*/
#include <stdio.h>
#include "hello.h" /* Generated by rpcgen from hello.x */
int main(int argc, char *argv[]) {
CLIENT *client;
char* *return_value;
int filler;
char *server;
/*
We must specify a host on which to run. We will get the host name
from the command line as argument 1.
*/
if (argc != 2) {
fprintf(stderr, "Usage: %s host_name\n", *argv);
exit(1);
}
server = argv[1];
/*
Generate the client handle to call the server
*/
if ((client=clnt_create(server, DISPLAY_PRG,
DISPLAY_VER, "tcp")) == (CLIENT *) NULL) {
clnt_pcreateerror(server);
exit(2);
}
printf("client : Calling function.\n");
return_value = print_hello_1((void *) &filler, client);
if (*return_value) {
printf("server returned message : %s\n", *return_value);
printf("client : Mission accomplished.\n");
} else {
printf("client : Unable to display message.\n");
}
return 0;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.