fork download
  1. #include<rpc/rpc.h>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<math.h>
  5.  
  6. square_out *squareproc_1_svc(square_in *inp,struct svc_req *rqstp)
  7. {
  8. static square_out out;
  9. out.res1= inp->arg1 * inp->arg1;
  10. return(&out);
  11. }
  12.  
  13. // CLIENT FILENAME: client.c
  14. #include<errno.h>
  15. #include<rpc/rpc.h>
  16. #include<stdio.h>
  17. #include<stdlib.h>
  18. #include<math.h>
  19.  
  20. int main(int argc,char **argv)
  21. {
  22. CLIENT *cl;
  23. square_in in;
  24. square_out *outp;
  25. f(argc!=3)
  26. {
  27. printf("\n\n error:insufficient arguments!!!");
  28. exit(-1);
  29. }
  30.  
  31. cl=clnt_create(argv[1],SQUARE_PROG,SQUARE_VERS,"tcp");
  32. in.arg1=atol(argv[2]);
  33.  
  34. if(cl==NULL)
  35. {
  36. printf("\nerror:%s",strerror(errno));
  37. exit(-1);
  38. }
  39.  
  40. if((outp=squareproc_1(&in,cl))==NULL)
  41. {
  42. printf("\nerror :%s",clnt_sperror(cl,argv[1]));
  43. exit(-1);
  44. }
  45.  
  46. printf("\n\n result is : %ld",outp->res1);
  47. exit(0);
  48. }
  49.  
  50. // .h FILENAME: square.h
  51.  
  52. struct square_in
  53. {
  54. /*input arg*/
  55. long arg1;
  56. };
  57.  
  58. struct square_out
  59. {
  60. /*op result*/
  61. long res1;
  62. };
  63.  
  64. program SQUARE_PROG
  65. {
  66. version SQUARE_VERS
  67. {
  68. square_out SQUAREPROC(square_in)=1; /*proc no=1*/
  69. }=1; /*version no*/
  70. }=0x31230000;/*prog no*/
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:6:1: error: unknown type name ‘square_out’; did you mean ‘quad_t’?
 square_out *squareproc_1_svc(square_in *inp,struct svc_req *rqstp)
 ^~~~~~~~~~
 quad_t
prog.c:6:30: error: unknown type name ‘square_in’
 square_out *squareproc_1_svc(square_in *inp,struct svc_req *rqstp)
                              ^~~~~~~~~
prog.c: In function ‘main’:
prog.c:23:2: error: unknown type name ‘square_in’
  square_in in;
  ^~~~~~~~~
prog.c:24:2: error: unknown type name ‘square_out’; did you mean ‘quad_t’?
  square_out *outp;
  ^~~~~~~~~~
  quad_t
prog.c:25:2: warning: implicit declaration of function ‘f’ [-Wimplicit-function-declaration]
  f(argc!=3)
  ^
prog.c:25:12: error: expected ‘;’ before ‘{’ token
  f(argc!=3)
            ^
            ;
      {
      ~      
prog.c:32:4: error: request for member ‘arg1’ in something not a structure or union
  in.arg1=atol(argv[2]);
    ^
prog.c:36:32: warning: implicit declaration of function ‘strerror’; did you mean ‘perror’? [-Wimplicit-function-declaration]
            printf("\nerror:%s",strerror(errno));
                                ^~~~~~~~
                                perror
prog.c:36:29: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
            printf("\nerror:%s",strerror(errno));
                            ~^  ~~~~~~~~~~~~~~~
                            %d
prog.c:40:15: warning: implicit declaration of function ‘squareproc_1’ [-Wimplicit-function-declaration]
      if((outp=squareproc_1(&in,cl))==NULL)
               ^~~~~~~~~~~~
prog.c:40:14: warning: assignment to ‘int *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
      if((outp=squareproc_1(&in,cl))==NULL)
              ^
prog.c:46:40: error: request for member ‘res1’ in something not a structure or union
      printf("\n\n result is : %ld",outp->res1);
                                        ^~
prog.c: At top level:
prog.c:64:1: error: unknown type name ‘program’
 program SQUARE_PROG
 ^~~~~~~
prog.c:65:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 {
 ^
prog.c:70:2: error: expected identifier or ‘(’ before ‘=’ token
 }=0x31230000;/*prog no*/
  ^
stdout
Standard output is empty