Skip to content
Snippets Groups Projects
Commit 16a47c40 authored by MILON ETHAN's avatar MILON ETHAN
Browse files

small refacto

parent dd55cae5
Branches
No related merge requests found
Pipeline #107912 passed with stages
in 6 seconds
#include <fcntl.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdint.h>
#include <stdio.h>
#include "utils/error.h"
#include "server/server.h"
#include <sys/poll.h>
#include <unistd.h>
#include "utils/error.h"
#include "server/server.h"
#include "utils/error_generator.h"
#define BUFF_SIZE 1024
/**
* struct args - Argument pour le thread
*/
struct args {
int max_error;
double error_rate;
struct sockaddr_in *addr;
};
/**
* @brief fonction principale d'une connexion sur le proxy
* @brief Routine du thread lors d'une nouvelle connection
*
* @param client
* @param arg
* @param client File descriptor du client
* @param arg Argument du thread
*/
void proxy_thread(int client, void *arg)
{
......@@ -75,6 +78,7 @@ void proxy_thread(int client, void *arg)
int main(int argc, char *argv[])
{
char buff[BUFF_SIZE];
// initialisation
Server *server;
struct sockaddr_in addr;
......@@ -97,6 +101,14 @@ int main(int argc, char *argv[])
CHK(server_start(server, proxy_thread, &args));
while (1) {
// attente d'une commande
CHKN(fgets(buff, BUFF_SIZE, stdin));
// si la commande est "quit", on quitte le serveur
if (strcmp(buff, "quit\n") == 0)
break;
}
CHK(server_join(server));
// nettoyage
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment