Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
project_TRTP
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Samuel de Meester de Ravestein
project_TRTP
Validations
8f5fd02f
Valider
8f5fd02f
rédigé
3 years ago
par
Samuel de Meester de Ravestein
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
make progress on the sender
parent
41d422fa
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
4
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
Makefile
+1
-1
1 ajout, 1 suppression
Makefile
headers/sender_utils.h
+5
-0
5 ajouts, 0 suppression
headers/sender_utils.h
src/sender.c
+47
-10
47 ajouts, 10 suppressions
src/sender.c
src/sender_utils.c
+0
-0
0 ajout, 0 suppression
src/sender_utils.c
avec
53 ajouts
et
11 suppressions
Makefile
+
1
−
1
Voir le fichier @
8f5fd02f
...
...
@@ -7,7 +7,7 @@ HEADERS_DIR = -Iheaders
LDFLAGS
=
-lz
# Adapt these as you want to fit with your project
SENDER_SOURCES
=
$(
wildcard src/sender.c src/log.c src/our_utils.c src/packet_interface.c
)
SENDER_SOURCES
=
$(
wildcard src/sender.c src/log.c src/our_utils.c src/packet_interface.c
src/sender_utils.c
)
RECEIVER_SOURCES
=
$(
wildcard src/receiver.c src/log.c src/our_utils.c src/packet_interface.c src/receiver_utils.c
)
SENDER_OBJECTS
=
$(
SENDER_SOURCES:.c
=
.o
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
headers/sender.h
→
headers/sender
_utils
.h
+
5
−
0
Voir le fichier @
8f5fd02f
#ifndef __SENDER_UTILS_H_
#define __SENDER_UTILS_H_
#include
<fcntl.h>
#include
<poll.h>
#include
<stdlib.h>
...
...
@@ -14,3 +17,5 @@
#include
"packet_interface.h"
#endif
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
src/sender.c
+
47
−
10
Voir le fichier @
8f5fd02f
#include
"../headers/sender.h"
#include
"../headers/sender
_utils
.h"
int
print_usage
(
char
*
prog_name
)
{
ERROR
(
"Usage:
\n\t
%s [-f filename] [-s stats_filename] [-c] receiver_ip receiver_port"
,
prog_name
);
...
...
@@ -55,6 +55,7 @@ int main(int argc, char **argv) {
DEBUG
(
"You can only see me if %s"
,
"you built me using `make debug`"
);
ERROR
(
"This is not an error, %s"
,
"now let's code!"
);
// Now let's code!
// Alright :-)
...
...
@@ -77,8 +78,8 @@ int main(int argc, char **argv) {
}
// *** Step 2: Prepare to send ***
int
fd
=
open
(
filename
,
O_RDONLY
);
if
(
fd
==
-
1
)
int
sending_
fd
=
open
(
filename
,
O_RDONLY
);
if
(
sending_
fd
==
-
1
)
{
close
(
socket_fd
);
ERROR
(
"An error occured while trying to open the file
\n
"
);
...
...
@@ -88,20 +89,56 @@ int main(int argc, char **argv) {
// *** Step: Time for sending ***
struct
pollfd
*
pfd
=
(
struct
pollfd
*
)
calloc
(
1
,
sizeof
(
struct
pollfd
));
if
(
pfd
==
NULL
)
if
(
pfd
s
==
NULL
)
{
close
(
socket_fd
);
close
(
sending_fd
);
ERROR
(
"Calloc failed
\n
"
);
return
EXIT_FAILURE
;
}
pfd
->
fd
=
socket_fd
;
pfd
->
events
=
POLLIN
|
POLLOUT
;
// want to read and write from the socket
// Socket -> we want to read and write from it
pfd
[
0
].
fd
=
socket_fd
;
pfd
[
0
].
events
=
POLLIN
|
POLLOUT
;
bool
connected
=
true
;
while
(
connected
)
bool
sending_file_read
=
false
;
bool
ack_received
=
false
;
int
rvalue
;
while
(
!
(
sending_file_read
&&
ack_received
))
{
/* code */
// Blocking calling system
rvalue
=
poll
(
pfd
,
1
,
-
1
);
// -1 means waits forever
if
(
rvalue
==
-
1
)
{
close
(
socket_fd
);
close
(
sending_fd
);
ERROR
(
"poll function failed
\n
"
);
return
EXIT_FAILURE
;
}
if
(
!
(
sending_file_read
)
&&
(
pfd
->
revents
&
POLLOUT
)
)
{
rvalue
=
read_and_send
();
if
(
rvalue
==
-
1
)
{
close
(
socket_fd
);
close
(
sending_fd
);
ERROR
(
"poll function failed
\n
"
);
return
EXIT_FAILURE
;
}
}
else
if
(
pfd
->
revents
&
POLLIN
)
{
rvalue
=
handle_returning_pkt
();
if
(
rvalue
==
-
1
)
{
close
(
socket_fd
);
close
(
sending_fd
);
ERROR
(
"poll function failed
\n
"
);
return
EXIT_FAILURE
;
}
}
}
...
...
@@ -156,7 +193,7 @@ int main(int argc, char **argv) {
// }
// pkt_del(pkt);
close
(
fd
);
close
(
sending_
fd
);
close
(
socket_fd
);
return
EXIT_SUCCESS
;
}
Ce diff est replié.
Cliquez pour l'agrandir.
src/sender_utils.c
0 → 100644
+
0
−
0
Voir le fichier @
8f5fd02f
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter