view gara/main.c @ 71:75de5903355c

Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
author June Park <parkjune1995@gmail.com>
date Sun, 28 Dec 2025 20:34:22 -0800
parents a0f0ad5e42eb
children 19cccf6e866a
line wrap: on
line source

#include "seobeo/seobeo.h"
#include "stdio.h"

void HandleClientRequest(Seobeo_Handle *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_Handle *server = Seobeo_Stream_Handle_Server_Create(NULL,  PORT);

  printf("Server running\n");
  while (1)
  {
    Seobeo_Handle *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;
}