blob: 57c249278a723fbfce62a7b9995eabd688cda61d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include "ezipc.h"
#include "common.h"
int main(void)
{
ezi_conn* conn = ezi_create(EZIPC_TEST_PATH);
assert(conn);
msg ok;
ok.type = MSG_OK;
strcpy((char*)ok.data, "ok");
msg quit;
quit.type = MSG_EXIT;
strcpy((char*)quit.data, "exit");
int counter = 0;
bool running = true;
while(running)
{
msg rmsg;
size_t rsz = sizeof(rmsg) - 100; // truncate test
if(ezi_recv(conn, &rmsg, &rsz))
{
switch(rmsg.type)
{
case MSG_TEXT:
{
printf("got: '%s'\n", (char*)rmsg.data);
counter++;
if(counter >= 10)
{
if(!ezi_send(conn, &quit, sizeof(quit)))
printf("Could not send msg to client\n");
counter = 0;
}
else
{
if(!ezi_send(conn, &ok, sizeof(ok)))
printf("Could not send msg to client\n");
}
} break;
default: break;
}
}
else
{
printf("Recv error, resetting...\n");
ezi_destroy(conn);
conn = ezi_create(EZIPC_TEST_PATH);
assert(conn);
}
}
ezi_destroy(conn);
return 0;
}
#define EZIPC_IMPL
#include "ezipc.h"
|