From c7aafcfb4cff44a60fa54fa55cd9e3519b30e720 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 20 Aug 2013 19:20:42 -0400 Subject: [PATCH] Lossless UDP tests fixed. --- testing/Lossless_UDP_testclient.c | 32 +++++++++++++++---------------- testing/Lossless_UDP_testserver.c | 32 +++++++++++++++---------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c index 575be2bd..0218de4f 100644 --- a/testing/Lossless_UDP_testclient.c +++ b/testing/Lossless_UDP_testclient.c @@ -122,8 +122,8 @@ void printconnection(int connection_id) /*( receive packets and send them to the packethandler */ /*run doLossless_UDP(); */ -void Lossless_UDP() -{ +//void Lossless_UDP() +//{ /* IP_Port ip_port; uint8_t data[MAX_UDP_PACKET_SIZE]; uint32_t length; @@ -140,11 +140,11 @@ void Lossless_UDP() /* } */ /* }*/ - networking_poll(); + //networking_poll(); - doLossless_UDP(); + //doLossless_UDP(); -} +//} int main(int argc, char *argv[]) { @@ -166,25 +166,26 @@ int main(int argc, char *argv[]) /* bind to ip 0.0.0.0:PORT */ IP ip; ip.i = 0; - init_networking(ip, PORT); + Lossless_UDP * ludp = new_lossless_udp(new_networking(ip, PORT)); perror("Initialization"); IP_Port serverip; serverip.ip.i = inet_addr(argv[1]); serverip.port = htons(atoi(argv[2])); printip(serverip); - int connection = new_connection(serverip); + int connection = new_connection(ludp, serverip); uint64_t timer = current_time(); while (1) { /* printconnection(connection); */ - Lossless_UDP(); + networking_poll(ludp->net); + do_lossless_udp(ludp); - if (is_connected(connection) == 3) { + if (is_connected(ludp, connection) == 3) { printf("Connecting took: %llu us\n", (unsigned long long)(current_time() - timer)); break; } - if (is_connected(connection) == 0) { + if (is_connected(ludp, connection) == 0) { printf("Connection timeout after: %llu us\n", (unsigned long long)(current_time() - timer)); return 1; } @@ -194,25 +195,24 @@ int main(int argc, char *argv[]) timer = current_time(); - LosslessUDP_init(); /*read first part of file */ read = fread(buffer, 1, 512, file); while (1) { /* printconnection(connection); */ - Lossless_UDP(); + networking_poll(ludp->net); + do_lossless_udp(ludp); + if (is_connected(ludp, connection) == 3) { - if (is_connected(connection) == 3) { - - if (write_packet(connection, buffer, read)) { + if (write_packet(ludp, connection, buffer, read)) { /* printf("Wrote data.\n"); */ read = fread(buffer, 1, 512, file); } /* printf("%u\n", sendqueue(connection)); */ - if (sendqueue(connection) == 0) { + if (sendqueue(ludp, connection) == 0) { if (read == 0) { printf("Sent file successfully in: %llu us\n", (unsigned long long)(current_time() - timer)); break; diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index dec50d7f..c3212888 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c @@ -118,8 +118,8 @@ void printconnection(int connection_id) /* receive packets and send them to the packethandler * run doLossless_UDP(); */ -void Lossless_UDP() -{ +//void Lossless_UDP() +//{ // IP_Port ip_port; // uint8_t data[MAX_UDP_PACKET_SIZE]; // uint32_t length; @@ -135,10 +135,10 @@ void Lossless_UDP() //} // } - networking_poll(); + // networking_poll(); - doLossless_UDP(); -} + //doLossless_UDP(); +//} int main(int argc, char *argv[]) @@ -161,20 +161,19 @@ int main(int argc, char *argv[]) //bind to ip 0.0.0.0:PORT IP ip; ip.i = 0; - init_networking(ip, PORT); + Lossless_UDP * ludp = new_lossless_udp(new_networking(ip, PORT)); perror("Initialization"); int connection; uint64_t timer = current_time(); - LosslessUDP_init(); - while (1) { - Lossless_UDP(); - connection = incoming_connection(); + networking_poll(ludp->net); + do_lossless_udp(ludp); + connection = incoming_connection(ludp); if (connection != -1) { - if (is_connected(connection) == 2) { + if (is_connected(ludp, connection) == 2) { printf("Received the connection.\n"); } @@ -189,11 +188,12 @@ int main(int argc, char *argv[]) while (1) { //printconnection(0); - Lossless_UDP(); + networking_poll(ludp->net); + do_lossless_udp(ludp); - if (is_connected(connection) >= 2) { - kill_connection_in(connection, 3000000); - read = read_packet(connection, buffer); + if (is_connected(ludp, connection) >= 2) { + kill_connection_in(ludp, connection, 3000000); + read = read_packet(ludp, connection, buffer); if (read != 0) { // printf("Received data.\n"); @@ -202,7 +202,7 @@ int main(int argc, char *argv[]) } } - if (is_connected(connection) == 4) { + if (is_connected(ludp, connection) == 4) { printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); fclose(file); return 1;