diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..81d39d3 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/ProgC.iml b/.idea/ProgC.iml new file mode 100644 index 0000000..633cf01 --- /dev/null +++ b/.idea/ProgC.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ef004d1 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5cb7f0e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..9661ac7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProgC_Q.zip b/ProgC_Q.zip deleted file mode 100644 index 1562e5b..0000000 Binary files a/ProgC_Q.zip and /dev/null differ diff --git a/tsock.h b/tsock.h index 3cf7af6..b0d90ad 100644 --- a/tsock.h +++ b/tsock.h @@ -24,6 +24,41 @@ void printbuffer(int n); //-------------Définitions des fonctions------------- //--------------------------------------------------- +//-------------PRINTBUFFER +void printbuffer(int n) +{ + int r; + + if (n<10) + { + printf("[----%d",n); + } + if (n>=10 & n<100) + { + printf("[---%d",n); + } + if (n>=100 & n<1000) + { + printf("[--%d",n); + } + if (n>=1000 & n<10000) + { + printf("[--%d",n); + } + if (n>=10000 & n<100000) + { + printf("[-%d",n); + } + if (n>=100000 & n<1000000) + { + printf("[%d",n); + } + if (n>=1000000) + { + printf("Trop de messages à envoyer (n>1000000 \n"); + exit(1); + } +} //Construction des messages void construire_message(char *message, char motif, int lg ,int i) @@ -31,13 +66,11 @@ void construire_message(char *message, char motif, int lg ,int i) { char alphabet[] = "abcdefghijklmnopqrstuvwxyz"; if (i>26) - { - motif=alphabet[i%26-1]; - } + motif=alphabet[i%26-1]; + else - { - motif=alphabet[i-1]; - } + motif = alphabet[i - 1]; + for (int j=0;j=10 & n<100) - { - printf("[---%d",n); - } - if (n>=100 & n<1000) - { - printf("[--%d",n); - } - if (n>=1000 & n<10000) - { - printf("[--%d",n); - } - if (n>=10000 & n<100000) - { - printf("[-%d",n); - } - if (n>=100000 & n<1000000) - { - printf("[%d",n); - } - if (n>=1000000) - { - printf("Trop de messages à envoyer (n>1000000 \n"); - exit(1); - } -} + //---------------------------------------------------- //----------------Envoi UDP--------------------------- @@ -284,12 +284,12 @@ void ClientTCP (int port, int nb_message , int lg_msg , char* dest) construire_message(message,motif,lg_msg,i); -// printbuffer(i); + printbuffer(i); afficher_message(message,lg_msg); //Envoi du message - if ((envoi=sendto(sock,message,lg_msg,0,(struct sockaddr*)&addr_distant,lg_addr_distant))==-1) + if ((envoi=write(sock,message,lg_msg/*,0,(struct sockaddr*)&addr_distant,lg_addr_distant)*/))==-1) { printf("Echec de l'envoi du message (fonction send en défaut)\n"); exit(1); @@ -396,7 +396,7 @@ void ServeurTCP(int port , int nb_message, int lg_msg) printf("Echec de la lecture du message entrant \n"); exit(1); } -// printbuffer(i); + printbuffer(i); afficher_message(message, lg_recv); } //Fermeture connexion diff --git a/tsock_v3 b/tsock_v3 index fe680f6..720f12d 100644 Binary files a/tsock_v3 and b/tsock_v3 differ