#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"