comparison 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
comparison
equal deleted inserted replaced
44:0cfd7d9277b0 45:ac8626c7859c
1 #include "seobeo/seobeo.h"
2 #include "stdio.h"
3
4 void HandleClientRequest(Seobeo_PHandle p_cli_handle) {
5 char *hello = "Hello good sir";
6 Seobeo_Handle_Queue(p_cli_handle, (uint8_t*)hello, 14);
7 Seobeo_Handle_Flush(p_cli_handle);
8
9 while (1)
10 {
11 int n = Seobeo_Handle_Read(p_cli_handle);
12 if (n > 0)
13 {
14 printf(p_cli_handle->read_buffer);
15 Seobeo_Handle_Consume(p_cli_handle, n);
16 }
17 }
18 }
19
20 int main()
21 {
22
23 printf("Server initializing\n");
24 const char *PORT = "3322";
25 Seobeo_PHandle server = Seobeo_Stream_Handle_Server_Create(NULL, PORT);
26
27 printf("Server running\n");
28 while (1)
29 {
30 Seobeo_PHandle p_cli_handle =
31 Seobeo_Stream_Handle_Server_Accept(server);
32 if (!p_cli_handle) continue;
33
34 if (fork() == 0)
35 {
36 HandleClientRequest(p_cli_handle);
37 _exit(0);
38 }
39 }
40
41 return 0;
42 }