Annotation of libaitrpc/example/tsrv.c, revision 1.1.1.1.2.3
1.1 misho 1: #include <stdio.h>
2: #include <aitrpc.h>
3:
4:
1.1.1.1.2.2 misho 5: int aaa(rpc_func_t *f, int in, rpc_val_t *iv)
1.1 misho 6: {
1.1.1.1.2.2 misho 7: RPC_CALLBACK_CHK_NUM_ARGS(f, in);
1.1 misho 8:
9: printf("%s(%d): Piuk! %s\n", __func__, __LINE__, f->func_name);
10: return 0;
11: }
12:
1.1.1.1.2.2 misho 13: int BBB(rpc_func_t *f, int in, rpc_val_t *iv)
1.1 misho 14: {
15: rpc_val_t *v;
16:
1.1.1.1.2.2 misho 17: RPC_CALLBACK_CHK_NUM_ARGS(f, in);
1.1 misho 18:
1.1.1.1.2.2 misho 19: printf("%s(%d): Piuk! %s %d %s\n", __func__, __LINE__, f->func_name,
20: RPC_GET_I32(&iv[0]), RPC_GET_STR(&iv[1]));
1.1 misho 21:
22: rpc_srv_declValsCall(f, 3);
23: rpc_srv_getValsCall(f, &v);
24: RPC_SET_BUF(&v[0], "00!oo", 6);
25: RPC_SET_I8(&v[1], 65);
26: RPC_SET_STR(&v[2], "Oho boho i cheburashka");
27: return 33;
28: }
29:
30: int main()
31: {
32: rpc_srv_t *srv;
33: rpc_func_t *f;
1.1.1.1.2.3! misho 34: pthread_t tid[2];
! 35: int ret;
1.1 misho 36:
37: srv = rpc_srv_initServer(100, 2, 1, 2, "0.0.0.0", 11111);
38: if (!srv) {
39: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
40: return 1;
41: }
42:
1.1.1.1.2.2 misho 43: if (rpc_srv_initBLOBServer(srv, 0, "/tmp")) {
44: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
45: return 1;
46: }
47:
1.1 misho 48: rpc_srv_registerCall(srv, NULL, "aaa", 0);
49: rpc_srv_registerCall(srv, NULL, "BBB", 3);
50: rpc_srv_registerCall(srv, NULL, "dummy", 1);
51: rpc_srv_registerCall(srv, NULL, "xYz", 2);
52:
53: rpc_srv_unregisterCall(srv, NULL, "dummy");
54:
55: for (f = srv->srv_funcs; f; f = f->func_next)
56: printf("func::name=%s args=%d\n", f->func_name, f->func_args);
57:
1.1.1.1.2.1 misho 58: if (!fork()) {
59: setsid();
1.1 misho 60:
1.1.1.1.2.3! misho 61: pthread_create(&tid[1], NULL, rpc_srv_execBLOBServer, srv);
! 62: rpc_srv_execServer(srv);
1.1 misho 63: }
64:
1.1.1.1.2.2 misho 65: rpc_srv_endBLOBServer(srv);
1.1 misho 66: rpc_srv_endServer(srv);
67: return 0;
68: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>