#include #include #define RPC_CLIENT #include "msg.h" main(argc, argv) int argc; char *argv[]; { CLIENT *cl, *cl2; int i, j; char *rep=0; int ret; char*msg="hello"; int ints_in[8], ints_out[8], *ints_ptr; WSAEVENT eve[2]; WORD d; struct timeval tmout = { 25, 0 }; cl = clnt_create("localhost", MSGSERV, MSGSERV_V1, "tcp"); if (cl == NULL) { clnt_pcreateerror(argv[1]); exit (1); }else { printf("Connected to server 1\n"); } printf("Making second connection\n"); cl2 = clnt_create("localhost", MSGSERV, MSGSERV_V1, "tcp"); /* send the calls to server and return immediately */ printf("making first async call, store the Event object\n"); eve[0]= tcp_async_call(cl, sendmsg, (xdrproc_t)xdr_wrapstring, &msg); printf("making second async call, sever will reply in two seconds\n"); /* note, one can't have two pending async calls on the same client handle */ eve[1]= tcp_async_call(cl2, sendmsg, (xdrproc_t)xdr_wrapstring, &msg); /* now we wait on the returned event objects */ printf("now we wait for the events (for both calls to return)\n"); d = WSAWaitForMultipleEvents(2, eve, 1, WSA_INFINITE, 0); printf("Getting result for event %d\n", d); ret = tcp_async_call_getresult(cl, (xdrproc_t)xdr_wrapstring, &rep, tmout); printf("Got async reply: %d, %s\n", d, rep); WSACloseEvent(eve[0]); ret = tcp_async_call_getresult(cl2, (xdrproc_t)xdr_wrapstring, &rep, tmout); printf("Got async reply from second connection: %d, %s\n", d, rep); WSACloseEvent(eve[1]); for(i=0; i< 10; i++){ #ifndef RPC_RETURN_ARG printf("calling rpc using one arg form, return pointer\n"); rep = *sendmsg_1(&msg, cl); printf("Got reply: %s.\n", rep); #else printf("calling rpc using two arg form, return status, pass back by arg\n"); ret= sendmsg_1(cl, &msg, &rep); printf("Return code = %d, Got reply: %s.\n", ret, rep); #endif } for(i=0; i< 100; i++){ for(j=0; j<8; j++) ints_in[j]=i+j; #ifndef RPC_RETURN_ARG printf("calling rpc using one arg form, return pointer\n"); ints_ptr = sendintegers_1(ints_in, cl); printf("Got reply: "); #else printf("calling rpc using two arg form, return status, pass back by arg\n"); ret= sendintegers_1(cl, ints_in, ints_out); printf("Return code = %d, get numbers ", ret); ints_ptr = ints_out; #endif for(j=0;j<8; j++) printf("%d ", ints_ptr[j]); printf("\n"); } Sleep(1000); clnt_destroy(cl); clnt_destroy(cl2); return 0; }