Commit 3b48034229040cc5f60cfc6e3f2aaf831226c729
1 parent
351d9caa
Modification serveur
Showing
5 changed files
with
28 additions
and
8 deletions
Show diff stats
No preview for this file type
No preview for this file type
Sioux/client.c
... | ... | @@ -6,8 +6,11 @@ |
6 | 6 | #include <string.h> |
7 | 7 | #include <netdb.h> |
8 | 8 | #include <arpa/inet.h> |
9 | +#include <poll.h> | |
9 | 10 | |
10 | 11 | |
12 | +#define MAX_BUFF 100 | |
13 | + | |
11 | 14 | |
12 | 15 | int connexionServeur(char* host, char* service) |
13 | 16 | { |
... | ... | @@ -52,14 +55,19 @@ int main(void) |
52 | 55 | { |
53 | 56 | int sock_fd = connexionServeur("localhost", "2020"); |
54 | 57 | if(sock_fd<0) { fprintf(stderr, "Erreur connexionServeur\n"); return(-1); } |
58 | + | |
59 | + FILE* sockfd_stream = fdopen(sock_fd, "a+"); | |
60 | + | |
61 | + while(1) | |
62 | + { | |
63 | + fprintf(sockfd_stream, "YES !!! "); | |
64 | + } | |
65 | + | |
66 | + shutdown(sock_fd, SHUT_RDWR); | |
55 | 67 | |
56 | - struct pollfd pipe[2] | |
57 | - pipe[0].fd = sock_fd; | |
58 | - pipe[0].events = POLLIN; | |
59 | - pipe[1].fd = 0; | |
60 | - pipe[1].events = POLLIN; | |
61 | 68 | |
62 | 69 | return 0; |
63 | 70 | } |
64 | 71 | |
65 | 72 | |
73 | + | ... | ... |
Sioux/sioux
No preview for this file type
Sioux/sioux.c
... | ... | @@ -56,20 +56,32 @@ int initialisationServeur(char* service) |
56 | 56 | return sock_fd; |
57 | 57 | } |
58 | 58 | |
59 | -void mesCouilles(int sock) | |
59 | +void maFonction(int sock) | |
60 | 60 | { |
61 | 61 | printf("Connected\n"); |
62 | + char buffer[100]; | |
63 | + | |
64 | + FILE* sockdial_stream = fdopen(sock, "a+"); | |
65 | + | |
66 | + fgets(buffer, 100, sockdial_stream); | |
67 | + | |
68 | + printf("%s\n", buffer); | |
69 | + | |
70 | + fclose(sockdial_stream); | |
62 | 71 | } |
63 | 72 | |
64 | 73 | int boucleServeur(int socket, void(* fctConnex)(int)) |
65 | 74 | { |
66 | 75 | int sock_dial; |
76 | + | |
77 | + | |
78 | + | |
67 | 79 | while(1) |
68 | 80 | { |
69 | 81 | printf("MAH !\n"); |
70 | 82 | if((sock_dial=accept(socket, NULL, NULL)) < 0){ fprintf(stderr, "Error accept dialogue\n"); return -1; } |
71 | 83 | printf("ACCEPTED\n"); |
72 | - | |
84 | + | |
73 | 85 | fctConnex(sock_dial); |
74 | 86 | } |
75 | 87 | } |
... | ... | @@ -78,7 +90,7 @@ int boucleServeur(int socket, void(* fctConnex)(int)) |
78 | 90 | int main(void) |
79 | 91 | { |
80 | 92 | int sock_fd=initialisationServeur("2020"); |
81 | - boucleServeur(sock_fd, mesCouilles); | |
93 | + boucleServeur(sock_fd, maFonction); | |
82 | 94 | return 0; |
83 | 95 | } |
84 | 96 | ... | ... |