Annotation of libaitrpc/example/tcli.c, revision 1.1
1.1 ! misho 1: #include <stdio.h>
! 2: #include <aitrpc.h>
! 3:
! 4: //rpc_val_t valz[3];
! 5:
! 6: int main()
! 7: {
! 8: rpc_cli_t *cli;
! 9: int c, i, ret;
! 10: rpc_val_t valz[3], *v = NULL;
! 11:
! 12: cli = rpc_cli_openClient(100, 2, 2, "127.0.0.1", 11111);
! 13: if (!cli) {
! 14: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 15: return 1;
! 16: }
! 17:
! 18: RPC_SET_I32(&(valz[0]), 12345678);
! 19: RPC_SET_STR(&(valz[1]), "gniah_blah SHMINK!");
! 20: RPC_SET_U16(&(valz[2]), 123);
! 21: // for (i = 0; i < 1000000; i++)
! 22: if ((ret = rpc_cli_execCall(cli, NULL, "BBB", 3, valz, &c, &v)) < 0) {
! 23: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 24: return 2;
! 25: } else {
! 26: printf("ret=%d\n", ret);
! 27: printf("ret_val0:: %p %s len=%d type=%d\n",
! 28: &v[0], RPC_GET_BUF(&v[0]), RPC_LEN_VAL(&v[0]), RPC_TYPE_VAL(&v[0]));
! 29: printf("ret_val1:: %d len=%d type=%d\n",
! 30: RPC_GET_I8(&v[1]), RPC_LEN_VAL(&v[1]), RPC_TYPE_VAL(&v[1]));
! 31: printf("ret_val2:: is_empty? %d %s len=%d type=%d\n",
! 32: RPC_EMPTY_VAL(&v[2]), RPC_GET_STR(&v[2]), RPC_LEN_VAL(&v[2]), RPC_TYPE_VAL(&v[2]));
! 33: RPC_FREE_VAL(&v[0]);
! 34: RPC_FREE_VAL(&v[1]);
! 35: RPC_FREE_VAL(&v[2]);
! 36: rpc_cli_freeVals(c, v);
! 37: }
! 38: RPC_FREE_VAL(&valz[0]);
! 39: RPC_FREE_VAL(&valz[1]);
! 40: RPC_FREE_VAL(&valz[2]);
! 41:
! 42: if (rpc_cli_execCall(cli, NULL, "aaa", 0, NULL, &c, &v) < 0) {
! 43: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 44: return 3;
! 45: }
! 46:
! 47: if (rpc_cli_execCall(cli, NULL, CALL_SRVCLIENTS, 0, NULL, &c, &v) < 0) {
! 48: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 49: return 4;
! 50: }
! 51: for (i = 0; i < c; i++)
! 52: printf("registeredClient(%d)=%s\n", i, RPC_GET_STR(&*v));
! 53: rpc_cli_freeVals(c, v);
! 54: if (rpc_cli_execCall(cli, NULL, CALL_SRVCALLS, 0, NULL, &c, &v) < 0) {
! 55: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 56: return 5;
! 57: }
! 58: for (i = 0; i < c; i++)
! 59: printf("registeredCall(%d)=%s\n", i, RPC_GET_STR(&v[i]));
! 60: rpc_cli_freeVals(c, v);
! 61: if (rpc_cli_execCall(cli, NULL, CALL_SRVSESSIONS, 0, NULL, &c, &v) < 0) {
! 62: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 63: return 6;
! 64: }
! 65: printf("c=%d v=%p\n", c, v);
! 66: printf("session(%d:%d:%d) clients=%d\n", (uint8_t) RPC_GET_U8(&v[0]), (uint32_t) RPC_GET_U32(&v[1]),
! 67: RPC_GET_U32(&v[2]), RPC_GET_I32(&v[3]));
! 68: rpc_cli_freeVals(c, v);
! 69:
! 70: rpc_cli_closeClient(cli);
! 71: return 0;
! 72: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>