gestion père fils claire
This commit is contained in:
parent
371b9acc08
commit
9e501096b5
1 changed files with 11 additions and 2 deletions
13
tsock_v4.c
13
tsock_v4.c
|
@ -58,6 +58,9 @@ int main (int argc, char **argv) {
|
|||
int count = 0; // compte le nombre de messages transmis
|
||||
char* pmesg;
|
||||
|
||||
|
||||
printf("début père\n");
|
||||
|
||||
while ((c = getopt(argc, argv, "pscertun:l:")) != -1) {
|
||||
switch (c) {
|
||||
case 'c': /* Si on est en mode tcp, on devient client */
|
||||
|
@ -401,8 +404,8 @@ int main (int argc, char **argv) {
|
|||
}
|
||||
|
||||
printf("PUITS: connexion acceptée\n");
|
||||
printf("père\n");
|
||||
|
||||
printf("fin père\n");
|
||||
switch(fork()) {
|
||||
case -1:
|
||||
perror("erreur durant le fork\n");
|
||||
|
@ -411,7 +414,7 @@ int main (int argc, char **argv) {
|
|||
case 0:
|
||||
close(sock);
|
||||
sock = 0;
|
||||
printf("fils\n");
|
||||
printf("début fils\n");
|
||||
if (source == 1) {
|
||||
//envoi
|
||||
for(i=0; i<nb_message; i++) {
|
||||
|
@ -447,6 +450,11 @@ int main (int argc, char **argv) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (sock != 0) {
|
||||
printf("début père\n");
|
||||
} else {
|
||||
printf("fin fils\n");
|
||||
}
|
||||
}
|
||||
if (close(sock)==-1) {
|
||||
perror("Échec de destruction du socket\n");
|
||||
|
@ -457,4 +465,5 @@ int main (int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
free(pmesg);
|
||||
printf("fin père\n");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue