Couple fixes.

This commit is contained in:
irungentoo committed 2013-06-28 09:15:19 -04:00
1 parent 457feeed0b
commit fd44c68801
3 files changed
+56 -39

No files matched your search

+26 -18
View File
@@ -3,7 +3,7 @@
*
* Best used in combination with Lossless_UDP_testserver
*
* Compile with: gcc -O2 -Wall -o test ../core/network.c ../core/Lossless_UDP.c Lossless_UDP_testclient.c
* Compile with: gcc -O2 -Wall -o testclient ../core/network.c ../core/Lossless_UDP.c Lossless_UDP_testclient.c
*
* Command line arguments are the ip and port to cennect and send the file to.
* EX: ./test 127.0.0.1 33445 filename.txt
@@ -40,6 +40,29 @@ void printpacket(char * data, uint32_t length, IP_Port ip_port)
printf("\n--------------------END-----------------------------\n\n\n");
}
//recieve packets and send them to the packethandler
//run doLossless_UDP();
void Lossless_UDP()
{
IP_Port ip_port;
char data[MAX_UDP_PACKET_SIZE];
uint32_t length;
while(recievepacket(&ip_port, data, &length) != -1)
{
if(LosslessUDP_handlepacket(data, length, ip_port))
{
printpacket(data, length, ip_port);
}
else
{
printf("Received handled packet with length: %u\n", length);
}
}
doLossless_UDP();
}
int main(int argc, char *argv[])
{
@@ -68,7 +91,7 @@ int main(int argc, char *argv[])
uint64_t timer = current_time();
while(1)
{
Lossless_UDP();
if(is_connected(connection) == 3)
{
printf("Connecting took: %llu us", (unsigned long long)(current_time() - timer));
@@ -83,28 +106,13 @@ int main(int argc, char *argv[])
}
timer = current_time();
IP_Port ip_port;
char data[MAX_UDP_PACKET_SIZE];
uint32_t length;
//read first part of file
read = fread(buffer, 1, 128, file);
while(1)
{
while(recievepacket(&ip_port, data, &length) != -1)
{
if(LosslessUDP_handlepacket(data, length, ip_port))
{
printpacket(data, length, ip_port);
}
else
{
printf("Received handled packet with length: %u\n", length);
}
}
doLossless_UDP();
Lossless_UDP();
if(is_connected(connection) == 1)
{
+26 -17
View File
@@ -3,7 +3,7 @@
*
* Best used in combination with Lossless_UDP_testclient
*
* Compile with: gcc -O2 -Wall -o test ../core/network.c ../core/Lossless_UDP.c Lossless_UDP_testserver.c
* Compile with: gcc -O2 -Wall -o testserver ../core/network.c ../core/Lossless_UDP.c Lossless_UDP_testserver.c
*
* Command line argument is the name of the file to save what we recieve to.
* EX: ./test filename1.txt
@@ -41,6 +41,29 @@ void printpacket(char * data, uint32_t length, IP_Port ip_port)
printf("\n--------------------END-----------------------------\n\n\n");
}
//recieve packets and send them to the packethandler
//run doLossless_UDP();
void Lossless_UDP()
{
IP_Port ip_port;
char data[MAX_UDP_PACKET_SIZE];
uint32_t length;
while(recievepacket(&ip_port, data, &length) != -1)
{
if(LosslessUDP_handlepacket(data, length, ip_port))
{
printpacket(data, length, ip_port);
}
else
{
printf("Received handled packet with length: %u\n", length);
}
}
doLossless_UDP();
}
int main(int argc, char *argv[])
{
@@ -67,12 +90,10 @@ int main(int argc, char *argv[])
int connection;
uint64_t timer = current_time();
IP_Port ip_port;
char data[MAX_UDP_PACKET_SIZE];
uint32_t length;
while(1)
{
Lossless_UDP();
connection = incoming_connection();
if(connection != -1)
{
@@ -89,19 +110,7 @@ int main(int argc, char *argv[])
while(1)
{
while(recievepacket(&ip_port, data, &length) != -1)
{
if(LosslessUDP_handlepacket(data, length, ip_port))
{
printpacket(data, length, ip_port);
}
else
{
printf("Received handled packet with length: %u\n", length);
}
}
doLossless_UDP();
Lossless_UDP();
if(is_connected(connection) == 1)
{
read = read_packet(connection, buffer);