Skip to content
Extraits de code Groupes Projets
Valider d5a03758 rédigé par Samuel de Meester de Ravestein's avatar Samuel de Meester de Ravestein
Parcourir les fichiers

not so bad sender

parent 0065b4b2
Branches development_of_the_sender
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -42,7 +42,7 @@ int handle_returning_ack_nack(sender_state_t *state, int socket_fd);
int loop_over_timers(sender_state_t *state, int socket_fd);
int read_and_send();
int read_and_send(sender_state_t *state, int sending_fd, int socket_fd);
#endif
\ No newline at end of file
Aucun aperçu pour ce type de fichier
......@@ -139,7 +139,7 @@ int main(int argc, char **argv) {
}
else if ( !(sending_file_read_done) && (pfd->revents & POLLOUT) )
{
DEBUG("The sender will send a pkt on the socket");
DEBUG("The sender will send a pkt on the socket, the current window size is: %d", state->s_window_size);
sending_file_read_done = read_and_send(state, sending_fd, socket_fd);
if (sending_file_read_done == -1)
{
......
......@@ -120,7 +120,12 @@ int read_and_send(sender_state_t *state, int sending_fd, int socket_fd)
char packet_to_be_sent[PKT_MAX_LEN];
size_t len = PKT_MAX_LEN;
if (pkt_encode(pkt, packet_to_be_sent, &len) != PKT_OK) return -1;
pkt_status_code pkt_status = pkt_encode(pkt, packet_to_be_sent, &len);
if (pkt_status != PKT_OK)
{
DEBUG("pkt_encode for a PTYPE_DATA failed with status: %d", pkt_status);
return -1;
}
ssize_t sent = send(socket_fd, packet_to_be_sent, len, 0);
if (sent == -1) return -1;
......@@ -140,6 +145,6 @@ int read_and_send(sender_state_t *state, int sending_fd, int socket_fd)
off_t old_position = lseek(sending_fd, 0, SEEK_CUR);
off_t end_position = lseek(sending_fd, 0, SEEK_END);
// put back the reader cursor
lseek(sending_fd, 0, SEEK_SET);
lseek(sending_fd, old_position, SEEK_SET);
return old_position == end_position;
}
......@@ -4,4 +4,11 @@ network course. But when you manage to thrive throgh tough times then sweet thin
ahead. So good luck have a nice day of testing and remember : Tough Times Never Last.
PS: Drink a beer when you pass the test. Share your knowledge to others, computer
science isn't a field for selfishness. If you want to switch to Law, Economy, some shit
\ No newline at end of file
science isn't a field for selfishness. If you want to switch to Law, Economy, some shit
Hi Vany I love reading from you. As you know I'm working sometime a bit late in the night.
In a few hour you'll be in th famous "Salle Intel" to be really productive as you are.
Best regards,
Samuel
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter