From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 26-AUG-1994 12:00:42.83
To:	EVERHART
CC:	
Subj:	help for RPC on AXP

From: gding@paul.rutgers.edu (Guoyi Ding)
X-Newsgroups: comp.os.vms
Subject: help for RPC on AXP
Date: 25 Aug 1994 18:48:16 -0400
Organization: Rutgers University LCSR
Lines: 194
Message-ID: <33j73g$eq4@paul.rutgers.edu>
NNTP-Posting-Host: paul.rutgers.edu
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET



We have problem on runing RPC on AXP version 1.5
It seems that We can only make 46 "clnt_call" library 
call, i.e. after making 46 clnt_call, the client side
died. I have included the demo program in the following.
Can someone give me a hint on how to solve this problem?
Thanks.

----------------- CLNT.C ------------------------------

#include <stdio.h>
#include <time.h>
#include <ucx$inetdef.h>
#include <ucx$rpcxdr.h>
#include "prog.h"

static struct timeval TIMEOUT = { 25, 0 };

main(argc, argv)
     int argc;
     char *argv[];
{
    CLIENT *cl;      /* server handler */
    int arg, res;
    int i;

    cl = clnt_create(argv[1], PROG, VERS);

    for(i=0; i<50; i++) {
    arg = i;
    printf("argument = %d, i=%d\n", arg, i);
    clnt_call(cl, PLUSONE, xdr_int, &arg, xdr_int, &res, TIMEOUT);
    printf("result = %d\n", res);
}

     clnt_destroy(cl);
     exit(0);
}

/*
 * create client handler with tcp protocol.
 */

#include <in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#define bzero(s, n)   memset ((void*)(s), 0, (size_t)(n))
#define bcopy(b1, b2, length)  memcpy((b2), (b1), (length))

CLIENT *
clnt_create(hostname, prog, vers)
        char *hostname;
        unsigned prog;
        unsigned vers;
{
        struct hostent *h;
        struct protoent *p;
        struct sockaddr_in sin;
        int sock;
        CLIENT *client;

        h = gethostbyname(hostname);
        sin.sin_family = h->h_addrtype;
        sin.sin_port = 0;
        bzero(sin.sin_zero, sizeof(sin.sin_zero));
        bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length);
        p = getprotobyname("tcp");
        sock = RPC_ANYSOCK;

        client = clnttcp_create(&sin, prog, vers, &sock, 0,0);

        return (client);
}

------------------ SERV.C ---------------------------------------


#include <stdio.h>

#include <ucx$inetdef.h>

#include <ucx$rpcxdr.h>

#include "prog.h"



static void prog_1();

main()

{

        SVCXPRT *transp;

 

        (void)pmap_unset(PROG, VERS);



        transp = svctcp_create(RPC_ANYSOCK, 0, 0);



        svc_register(transp, PROG, VERS, prog_1, IPPROTO_TCP);

       

        printf("server has been started ...\n");

        svc_run();

}



static void

prog_1(rqstp, transp)

        struct svc_req *rqstp;

        SVCXPRT *transp;

{

        int argument;

        int result;



        switch (rqstp->rq_proc) {

        case NULLPROC:

                (void)svc_sendreply(transp, xdr_void, (char *)NULL);

                return;



        case PLUSONE:

               svc_getargs(transp, xdr_int, &argument);

               result = argument + 1;

               printf("argument=%d, result = %d\n", argument, result);

               svc_sendreply(transp, xdr_int, &result);

               return;

        default:

                svcerr_noproc(transp);

                return;

        }

}

------------------ MAKE.COM ----------------------------

$ write sys$output "compiling clnt.c ...."
$ cc /stand=vaxc clnt
$ write sys$output "compiling serv.c ...."
$ cc /stand=vaxc/nomember_ali serv
$ write sys$output "linking clnt ..."
$ link clnt,sys$input/opt
        sys$library:ucx$ipc_shr.exe/share
        sys$library:ucx$rpcxdr_shr/share
        sys$library:vaxcrtl/libr
$ write sys$output "linking serv ... "
$ link serv,sys$input/opt
        sys$library:ucx$ipc_shr.exe/share
        sys$library:ucx$rpcxdr_shr/share
        sys$library:vaxcrtl/libr
-- 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

       Guoyi Ding

E-mail: gding@paul.rutgers.edu

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

