// main.c #include #include #include #include "world.h" #include "error.h" #include "sock.h" int main(void) { enum error_t err = ERR_OK; int sock; err = sock_init(&sock); if (err) goto handle_error; char ibuf[8192] = { 0 }; read(sock, ibuf, 8192); struct world_t world = { 0 }; err = world_deserialise_str(&world, ibuf); if (err != ERR_OK) goto handle_error_sock; printf("CLIENT: (%zu %zu) ->", world.height++, world.width ++); printf(" (%zu %zu)\n", world.height, world.width); char obuf[8192] = { 0 }; err = world_serialise_buf(&world, obuf, 8192); if (err != ERR_OK) goto handle_error_sock; write(sock, obuf, 8192); close(sock); return ERR_OK; handle_error_sock: close(sock); handle_error: printf("CLIENT ERROR: %s\n", ERROR_STRS[err]); return err; }