Annotation of libaitrpc/example/tcli.c, revision 1.1.1.1.2.3
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;
1.1.1.1.2.3! misho 11: char *blob43 = malloc(512);
1.1 misho 12:
13: cli = rpc_cli_openClient(100, 2, 2, "127.0.0.1", 11111);
14: if (!cli) {
15: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
16: return 1;
17: }
18:
1.1.1.1.2.3! misho 19: strlcpy(blob43, "aaaaaaaaaaaaaaa cddddddddddddddd zzzzzzzzzzzzzzzzzzzzz !!!!\n\n\n675675676...\n", 512);
! 20:
1.1 misho 21: RPC_SET_I32(&(valz[0]), 12345678);
22: RPC_SET_STR(&(valz[1]), "gniah_blah SHMINK!");
1.1.1.1.2.3! misho 23: RPC_SET_U16(&(valz[2]), 512);
! 24: // RPC_SET_BLOB(&(valz[2]), blob43, 512);
1.1 misho 25: // for (i = 0; i < 1000000; i++)
26: if ((ret = rpc_cli_execCall(cli, NULL, "BBB", 3, valz, &c, &v)) < 0) {
27: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
28: return 2;
29: } else {
30: printf("ret=%d\n", ret);
1.1.1.1.2.2 misho 31: if (c && v) {
32: printf("ret_val0:: %p %s len=%d type=%d\n",
33: &v[0], RPC_GET_BUF(&v[0]), RPC_LEN_VAL(&v[0]), RPC_TYPE_VAL(&v[0]));
34: printf("ret_val1:: %d len=%d type=%d\n",
35: RPC_GET_I8(&v[1]), RPC_LEN_VAL(&v[1]), RPC_TYPE_VAL(&v[1]));
36: printf("ret_val2:: is_empty? %d %s len=%d type=%d\n",
37: RPC_EMPTY_VAL(&v[2]), RPC_GET_STR(&v[2]), RPC_LEN_VAL(&v[2]), RPC_TYPE_VAL(&v[2]));
38: RPC_FREE_VAL(&v[0]);
39: RPC_FREE_VAL(&v[1]);
40: RPC_FREE_VAL(&v[2]);
41: rpc_cli_freeVals(c, v);
42: }
1.1 misho 43: }
44: RPC_FREE_VAL(&valz[0]);
45: RPC_FREE_VAL(&valz[1]);
46: RPC_FREE_VAL(&valz[2]);
1.1.1.1.2.3! misho 47: free(blob43);
1.1 misho 48:
49: if (rpc_cli_execCall(cli, NULL, "aaa", 0, NULL, &c, &v) < 0) {
50: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
51: return 3;
52: }
53:
54: if (rpc_cli_execCall(cli, NULL, CALL_SRVCLIENTS, 0, NULL, &c, &v) < 0) {
55: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
56: return 4;
57: }
1.1.1.1.2.3! misho 58: printf("return=%d registeredClient\n", c);
1.1 misho 59: for (i = 0; i < c; i++)
1.1.1.1.2.3! misho 60: printf("registeredClient(%d)=%s\n", i, RPC_GET_STR(&v[i]));
1.1 misho 61: rpc_cli_freeVals(c, v);
1.1.1.1.2.3! misho 62: if (rpc_cli_execCall(cli, NULL, CALL_BLOBCLIENTS, 0, NULL, &c, &v) < 0) {
! 63: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 64: return 4;
! 65: }
! 66: printf("return=%d registeredBLOBClient\n", c);
! 67: for (i = 0; i < c; i++)
! 68: printf("registeredBLOBClient(%d)=%s\n", i, RPC_GET_STR(&*v));
! 69: rpc_cli_freeVals(c, v);
! 70:
1.1 misho 71: if (rpc_cli_execCall(cli, NULL, CALL_SRVCALLS, 0, NULL, &c, &v) < 0) {
72: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
73: return 5;
74: }
75: for (i = 0; i < c; i++)
76: printf("registeredCall(%d)=%s\n", i, RPC_GET_STR(&v[i]));
77: rpc_cli_freeVals(c, v);
78: if (rpc_cli_execCall(cli, NULL, CALL_SRVSESSIONS, 0, NULL, &c, &v) < 0) {
79: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
80: return 6;
81: }
82: printf("c=%d v=%p\n", c, v);
83: printf("session(%d:%d:%d) clients=%d\n", (uint8_t) RPC_GET_U8(&v[0]), (uint32_t) RPC_GET_U32(&v[1]),
84: RPC_GET_U32(&v[2]), RPC_GET_I32(&v[3]));
85: rpc_cli_freeVals(c, v);
86:
1.1.1.1.2.3! misho 87: // rpc_cli_execCall(cli, NULL, CALL_SRVSHUTDOWN, 0, NULL, 0, NULL);
1.1.1.1.2.1 misho 88:
1.1 misho 89: rpc_cli_closeClient(cli);
90: return 0;
91: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>