Mercurial
diff gara/main.c @ 45:ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Wed, 03 Dec 2025 20:51:50 -0800 |
| parents | |
| children | a0f0ad5e42eb |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gara/main.c Wed Dec 03 20:51:50 2025 -0800 @@ -0,0 +1,42 @@ +#include "seobeo/seobeo.h" +#include "stdio.h" + +void HandleClientRequest(Seobeo_PHandle p_cli_handle) { + char *hello = "Hello good sir"; + Seobeo_Handle_Queue(p_cli_handle, (uint8_t*)hello, 14); + Seobeo_Handle_Flush(p_cli_handle); + + while (1) + { + int n = Seobeo_Handle_Read(p_cli_handle); + if (n > 0) + { + printf(p_cli_handle->read_buffer); + Seobeo_Handle_Consume(p_cli_handle, n); + } + } +} + +int main() +{ + + printf("Server initializing\n"); + const char *PORT = "3322"; + Seobeo_PHandle server = Seobeo_Stream_Handle_Server_Create(NULL, PORT); + + printf("Server running\n"); + while (1) + { + Seobeo_PHandle p_cli_handle = + Seobeo_Stream_Handle_Server_Accept(server); + if (!p_cli_handle) continue; + + if (fork() == 0) + { + HandleClientRequest(p_cli_handle); + _exit(0); + } + } + + return 0; +}