#include "ezipc.h" #include "common.h" int main(void) { ezi_conn* conn = ezi_connect(EZIPC_TEST_PATH); assert(conn); msg ping = { .type = MSG_ECHO }; bool running = true; while(running) { char in[1024] = {0}; scanf("%[^\n]%*c", in); strcpy((char*)ping.data, in); if(!ezi_send(conn, &ping, sizeof(ping))) { printf("Send error, resetting...\n"); ezi_destroy(conn); conn = ezi_create(EZIPC_TEST_PATH); assert(conn); continue; } msg rmsg = {0}; size_t rsz = sizeof(rmsg); if(!ezi_recv(conn, &rmsg, &rsz)) { printf("Recv error, resetting...\n"); ezi_destroy(conn); conn = ezi_create(EZIPC_TEST_PATH); assert(conn); continue; } switch(rmsg.type) { case MSG_OK: { printf("+\n"); } break; case MSG_EXIT: { running = false; printf("told to exit...\n"); } break; case MSG_ECHO: // fallthrough default: exit(1); } } ezi_disconnect(conn); return 0; } #define EZIPC_IMPL #include "ezipc.h"