【发布时间】:2012-04-07 18:57:44
【问题描述】:
我正在尝试创建一个示例 RPC 程序以了解有关它的更多信息。它所做的只是承认我手头有一个工作的 RPC 程序,然后我才开始进一步干预它。在这里提到我的问题之前是我的代码,它非常简单:
/* myrpc.x file*/
program MESSAGEPROG {
version EVALMESSAGEVERS {
int EVALMESSAGE(string) = 1;
} = 1;
} = 0x20000002;
远程方法如下:
/* 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);
}
最后测试文件如下:
#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);
}
我的问题是,我得到输出:“失败”,表明我无法创建客户端。我使用 ubuntu/linux 作为我的平台并使用 C 作为我的编程语言。我在构建项目时没有遇到任何问题。
提前感谢您的宝贵时间。
【问题讨论】: