I’m trying to create a sample RPC program to learn more about it. What it does is only acknowledging that I have a working RPC program at hand before I start to meddle with it further. Before mentioning my problem here is my code, its very straightforward:
/* myrpc.x file*/
program MESSAGEPROG {
version EVALMESSAGEVERS {
int EVALMESSAGE(string) = 1;
} = 1;
} = 0x20000002;
The remote method is as follows:
/* Remote method on a .c file */
#include <stdio.h>
#include "myrpc.h"
int * evalmessage_1_svc(char **msg, struct svc_req *req)
{
static int result = 0;
printf("Message is: %s,\n",*msg);
return (&result);
}
Finally, the test file is as follows:
#include <stdio.h>
#include "myrpc.h"
main(int argc, char **argv)
{
CLIENT * clnt;
char * server;
char * msg;
server = argv[1];
msg = argv[2];
clnt = clnt_create(server, MESSAGEPROG, EVALMESSAGEVERS, "visible");
if (clnt == (CLIENT *)NULL) { printf("Failure\n"); }
int * answer;
answer = evalmessage_1(&msg,clnt);
clnt_destroy(clnt);
exit(0);
}
My problem is, I get the output : “Failure”, indicating that I couldn’t create the client. I’m using ubuntu/linux as my platform and using C as my programming language. I’m not having problems when building the project.
Thanks in advance for your time.
At the problematic line :
Changing the last parameter to “udp” worked for me.