Commit fff6f0370e40689fd0720531d0e4dc2183891fd8

Authored by skhinach
1 parent 32c9271a

modifs

Threads/Page.html 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +<!doctype html>
  2 +<html>
  3 + <head>
  4 + <meta charset ="utf-8">
  5 + <title> Interface Tangible </title>
  6 + </meta>
  7 + </head>
  8 + <body>
  9 + </body>
  10 +</html>
Threads/threadSocket.c
@@ -10,24 +10,27 @@ void* reponseConnexion(void* sock) @@ -10,24 +10,27 @@ void* reponseConnexion(void* sock)
10 { 10 {
11 11
12 printf("Connected\n"); 12 printf("Connected\n");
13 - char buffer[]= "HTTP/1.1 200 OK\nServer: Serveur fait maison\nContent-Type: text/html; charset=UTF-8\nConnection: Keep-alive\n\n<h1>Hey !</h1>";  
14 - 13 + char buff_rec[BUFF_SIZE];
  14 + char buffer[]="HTTP/1.1 200 OK\r\nServer: Serveur fait maison\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: Keep-alive\r\n\r\nPOST /Page.html HTTP/1.1\r\n\r\n";
  15 +
  16 +
15 FILE* sockdial_stream = fdopen(*((int*)(sock)), "a+"); 17 FILE* sockdial_stream = fdopen(*((int*)(sock)), "a+");
16 18
17 printf("Sock : %d // Stream : %p \n", *((int*)(sock)), sockdial_stream); 19 printf("Sock : %d // Stream : %p \n", *((int*)(sock)), sockdial_stream);
18 20
  21 + fgets(buff_rec, BUFF_SIZE, sockdial_stream);
19 fprintf(sockdial_stream, "%s", buffer); 22 fprintf(sockdial_stream, "%s", buffer);
20 23
21 - while(strcmp(buffer, "EXIT\n")!=0)  
22 - { 24 + //while(strcmp(buffer, "EXIT\n")!=0)
  25 + //{
23 printf("WAIT\n"); 26 printf("WAIT\n");
24 - fgets(buffer, BUFF_SIZE, sockdial_stream); 27 + // fgets(buff_rec, BUFF_SIZE, sockdial_stream);
25 28
26 - printf("Le message reçu : %s", buffer); 29 + printf("Le message reçu : %s", buff_rec);
27 30
28 fprintf(sockdial_stream, "Ceci est une réponse du serveur TCP.\n"); 31 fprintf(sockdial_stream, "Ceci est une réponse du serveur TCP.\n");
29 32
30 - } 33 + //}
31 34
32 strcpy(buffer, "START"); 35 strcpy(buffer, "START");
33 printf("Fin de la connexion\n"); 36 printf("Fin de la connexion\n");
No preview for this file type
1 #include <stdlib.h> 1 #include <stdlib.h>
2 #include <stdio.h> 2 #include <stdio.h>
  3 +#include <unistd.h>
3 #include <getopt.h> 4 #include <getopt.h>
4 #include <string.h> 5 #include <string.h>
  6 +#include <signal.h>
5 #include "libnet.h" 7 #include "libnet.h"
6 8
7 9
  10 +int sock_fd;
  11 +
  12 +struct sigaction action;
  13 +
  14 +void handler(int sig)
  15 +{
  16 + if(sig==SIGINT)
  17 + {
  18 + printf("\nINTERRUPTION SOCKET : %d\n\n", sock_fd);
  19 + close(sock_fd);
  20 + exit(1);
  21 + }
  22 +}
  23 +
  24 +
8 void argPortParsing(int argc, char* argv[], char* port) 25 void argPortParsing(int argc, char* argv[], char* port)
9 { 26 {
10 struct option port_arg={"port", 1, NULL, 'p'}; 27 struct option port_arg={"port", 1, NULL, 'p'};
@@ -30,8 +47,8 @@ int main(int argc, char* argv[]) @@ -30,8 +47,8 @@ int main(int argc, char* argv[])
30 char port[10]="80"; 47 char port[10]="80";
31 argPortParsing(argc, argv, port); 48 argPortParsing(argc, argv, port);
32 49
33 -  
34 - int sock_fd; 50 + action.sa_handler=&handler;
  51 + sigaction(SIGINT, &action, NULL);
35 52
36 if( (sock_fd=initialisationServeur(port)) ==-1 ) { fprintf(stderr, "Initialisation du serveur impossible\n"); return -1; } 53 if( (sock_fd=initialisationServeur(port)) ==-1 ) { fprintf(stderr, "Initialisation du serveur impossible\n"); return -1; }
37 54
libs/libthrd.a
No preview for this file type