diff --git a/headers/sender_utils.h b/headers/sender_utils.h index e6b3359794dfac3951c913b9bfcb3ca6102e1623..13508cc022b7cacaf7adbcb6d3d42ad1f19315fc 100644 --- a/headers/sender_utils.h +++ b/headers/sender_utils.h @@ -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 diff --git a/log.txt b/log.txt index c46e8c3e7e45a68de72ac17adf3281936e3f1060..e595e4d22b0f578cbb4b7238198157c9e8368071 100644 Binary files a/log.txt and b/log.txt differ diff --git a/src/sender.c b/src/sender.c index d8751fd976a4b2f645108478c95caba3d839ae33..593e5417e79d55d5f0919db2bf46ab848c563c3f 100644 --- a/src/sender.c +++ b/src/sender.c @@ -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) { diff --git a/src/sender_utils.c b/src/sender_utils.c index e30695c3f25b6bf0ef67a1338515dd4f9c5e31c0..69673a2e7e0f4b4c05c45ece30e68b866549035a 100644 --- a/src/sender_utils.c +++ b/src/sender_utils.c @@ -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; } diff --git a/test_files/long_message.txt b/test_files/long_message.txt index 2f8c6c62a2ed9362267177e1cca8ba2adb02233a..f531738996c10711fb2da8b1217480de8076a3d4 100644 --- a/test_files/long_message.txt +++ b/test_files/long_message.txt @@ -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