Comments
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#ifndef HTTP_SERVER_H
|
||||
#define HTTP_SERVER_H
|
||||
|
||||
// #include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef DEFAULT_HTML
|
||||
#define DEFAULT_HTML "index.html"
|
||||
@@ -24,15 +24,25 @@ typedef enum {
|
||||
HTTP_SRS_WONT_HANDLE,
|
||||
} HttpServerRunStatus;
|
||||
|
||||
// Structure ayant pour objectif de stocker tout ce qui est nécessaire au bon
|
||||
// fonctionnement du serveur.
|
||||
typedef struct {
|
||||
int port;
|
||||
int server_fd;
|
||||
unsigned int workers;
|
||||
struct sockaddr_in *address;
|
||||
int port; // Port du host
|
||||
int server_fd; // File descriptor du server
|
||||
unsigned int backlog; // Le nombre de clients possibles pouvant être en
|
||||
// attente.
|
||||
struct sockaddr_in *address; // L'adresse décrivant une socket internet.
|
||||
pid_t pid; // Le pid du parent en attente de requêtes.
|
||||
} HttpServer;
|
||||
|
||||
// On setup le server, avec son file descriptor, ses options, le bind et le
|
||||
// listen.
|
||||
HttpServerRunStatus http_server_setup(HttpServer *s);
|
||||
// Si tout est ok, on peut lancer le server, tant qu'il tourne, il peut
|
||||
// recevoir des clients.
|
||||
HttpServerRunStatus http_server_run(HttpServer *s);
|
||||
// Si pour quelques raisons il s'arrête, on free tout ce qu'il doit être
|
||||
// free.
|
||||
HttpServerRunStatus http_server_stop(HttpServer *s);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user