From: seantywork Date: Tue, 18 Feb 2025 07:26:06 +0000 (+0900) Subject: mod: cmd/rat-chat cmd/engine X-Git-Url: https://git.feebdaed.xyz/?a=commitdiff_plain;h=356af5c7fb6c8fc9e11c6e426382bc5eb4149c64;p=socialize.git mod: cmd/rat-chat cmd/engine --- diff --git a/Makefile b/Makefile index 1bcd41c..1816403 100644 --- a/Makefile +++ b/Makefile @@ -47,12 +47,12 @@ vendor: dev: $(OBJS) $(DEP_OBJS) - gcc $(GCC_DEV_FLAGS) $(INCLUDES) -o rat-chat.out cmd/rat-chat/main.c $(OBJS) $(DEP_OBJS) $(LIBS) + gcc $(GCC_DEV_FLAGS) $(INCLUDES) -o engine.out cmd/engine/main.c $(OBJS) $(DEP_OBJS) $(LIBS) release: $(OBJS) $(DEP_OBJS) - gcc $(GCC_REL_FLAGS) $(INCLUDES) -o rat-chat.out cmd/rat-chat/main.c $(OBJS) $(DEP_OBJS) $(LIBS) + gcc $(GCC_REL_FLAGS) $(INCLUDES) -o engine.out cmd/engine/main.c $(OBJS) $(DEP_OBJS) $(LIBS) diff --git a/cmd/engine/main.c b/cmd/engine/main.c new file mode 100644 index 0000000..6c3a564 --- /dev/null +++ b/cmd/engine/main.c @@ -0,0 +1,41 @@ + +#include "rat-chat/sock/core.h" +#include "rat-chat/front/core.h" + +#include "rat-chat/utils.h" +FILE* LOGFP; + +pthread_mutex_t G_MTX; + +int main(){ + + + srand((unsigned int)time(NULL)); + + LOGFP = fopen("log.txt","a"); + + + pthread_t sock_tid; + pthread_t front_tid; + + if (pthread_mutex_init(&G_MTX, NULL) != 0) { + printf("mutex init has failed\n"); + return -1; + } + + + pthread_create(&front_tid, NULL, (void*)front_listen_and_serve, NULL); + + sleepms(500); + + pthread_create(&sock_tid, NULL, (void*)sock_listen_and_serve, NULL); + + sleepms(500); + + + pthread_join(front_tid, NULL); + + fclose(LOGFP); + + +} \ No newline at end of file diff --git a/cmd/rat-chat/main.c b/cmd/rat-chat/main.c deleted file mode 100644 index 6c3a564..0000000 --- a/cmd/rat-chat/main.c +++ /dev/null @@ -1,41 +0,0 @@ - -#include "rat-chat/sock/core.h" -#include "rat-chat/front/core.h" - -#include "rat-chat/utils.h" -FILE* LOGFP; - -pthread_mutex_t G_MTX; - -int main(){ - - - srand((unsigned int)time(NULL)); - - LOGFP = fopen("log.txt","a"); - - - pthread_t sock_tid; - pthread_t front_tid; - - if (pthread_mutex_init(&G_MTX, NULL) != 0) { - printf("mutex init has failed\n"); - return -1; - } - - - pthread_create(&front_tid, NULL, (void*)front_listen_and_serve, NULL); - - sleepms(500); - - pthread_create(&sock_tid, NULL, (void*)sock_listen_and_serve, NULL); - - sleepms(500); - - - pthread_join(front_tid, NULL); - - fclose(LOGFP); - - -} \ No newline at end of file