1

这是我的客户代码

分类

#include "S.h"
 int main()
 {
   CLIENT *cl;
   cl=clnt_create("127.0.0.1",S_PROG,S_VERS,"tcp");
   struct st i,*o;i.a=3;
   o=square_1(&i,cl);
   printf("%d",o->a);
   return 0;
  }

服务器代码

服务器1.c

#include "S.h"
 struct st* square_1_svc(struct st *i,struct svc_req *r)
 {
   static struct st o;
   o.a=i->a*i->a;
   return &o;
 }

SX

struct st
{
  int a;
};
program S_PROG
{
   version S_VERS
   {
       st square(st)=1;
   }=1;
}=OX31231234;

编译过程

rpcgen -C S.x
gcc -c S_xdr.c
gcc -c S_clnt.c
gcc -c S_svc.c
gcc -c cl.c
gcc -c server1.c

手动构建目标文件

gcc -o rpccl S_xdr.o S_clnt.o cl.o -lnsl
gcc -o rpcserver1 S_xdr.o S_svc.o server1.o -lnsl

./rpserver1
./spccl

当我在“./spccl”行中运行我的客户端输出文件时,我遇到了分段错误。

4

0 回答 0