Rewrite in C. Simple TCP listener.

This commit is contained in:
2025-09-13 00:57:47 +03:00
parent 418d33a6de
commit 39db2830e2
9 changed files with 149 additions and 77 deletions

36
src/httpserver.h Normal file
View File

@@ -0,0 +1,36 @@
//
// Created by nazar on 12.09.2025.
//
// https://datatracker.ietf.org/doc/html/rfc9112#name-message
#ifndef SIMPLEHTTPSERVER_H
#define SIMPLEHTTPSERVER_H
#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <arpa/inet.h>
struct HttpRequest
{
};
struct HttpResponse
{
};
struct HttpServer
{
struct HttpResponse* (*handleRequest)(struct HttpRequest* request);
};
void start_http_server(struct HttpServer* http_server, const char *addr, short port);
void process_conn(struct HttpServer* http_server, int server_fd, struct sockaddr* address, socklen_t* addr_len);
#endif //SIMPLEHTTPSERVER_H