summaryrefslogtreecommitdiff
path: root/testing/Lossless_UDP_testserver.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/Lossless_UDP_testserver.c')
-rw-r--r--testing/Lossless_UDP_testserver.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c
index dec50d7f..a82b787a 100644
--- a/testing/Lossless_UDP_testserver.c
+++ b/testing/Lossless_UDP_testserver.c
@@ -118,27 +118,27 @@ void printconnection(int connection_id)
118 118
119/* receive packets and send them to the packethandler 119/* receive packets and send them to the packethandler
120 * run doLossless_UDP(); */ 120 * run doLossless_UDP(); */
121void Lossless_UDP() 121//void Lossless_UDP()
122{ 122//{
123// IP_Port ip_port; 123// IP_Port ip_port;
124// uint8_t data[MAX_UDP_PACKET_SIZE]; 124// uint8_t data[MAX_UDP_PACKET_SIZE];
125// uint32_t length; 125// uint32_t length;
126// while (receivepacket(&ip_port, data, &length) != -1) { 126// while (receivepacket(&ip_port, data, &length) != -1) {
127 //if(rand() % 3 != 1)//add packet loss 127//if(rand() % 3 != 1)//add packet loss
128 //{ 128//{
129// if (LosslessUDP_handlepacket(data, length, ip_port)) { 129// if (LosslessUDP_handlepacket(data, length, ip_port)) {
130// printpacket(data, length, ip_port); 130// printpacket(data, length, ip_port);
131// } else { 131// } else {
132 //printconnection(0); 132//printconnection(0);
133// printf("Received handled packet with length: %u\n", length); 133// printf("Received handled packet with length: %u\n", length);
134// } 134// }
135 //} 135//}
136// } 136// }
137 137
138 networking_poll(); 138// networking_poll();
139 139
140 doLossless_UDP(); 140//doLossless_UDP();
141} 141//}
142 142
143 143
144int main(int argc, char *argv[]) 144int main(int argc, char *argv[])
@@ -161,20 +161,19 @@ int main(int argc, char *argv[])
161 //bind to ip 0.0.0.0:PORT 161 //bind to ip 0.0.0.0:PORT
162 IP ip; 162 IP ip;
163 ip.i = 0; 163 ip.i = 0;
164 init_networking(ip, PORT); 164 Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT));
165 perror("Initialization"); 165 perror("Initialization");
166 166
167 int connection; 167 int connection;
168 uint64_t timer = current_time(); 168 uint64_t timer = current_time();
169 169
170 LosslessUDP_init();
171
172 while (1) { 170 while (1) {
173 Lossless_UDP(); 171 networking_poll(ludp->net);
174 connection = incoming_connection(); 172 do_lossless_udp(ludp);
173 connection = incoming_connection(ludp);
175 174
176 if (connection != -1) { 175 if (connection != -1) {
177 if (is_connected(connection) == 2) { 176 if (is_connected(ludp, connection) == 2) {
178 printf("Received the connection.\n"); 177 printf("Received the connection.\n");
179 178
180 } 179 }
@@ -189,11 +188,12 @@ int main(int argc, char *argv[])
189 188
190 while (1) { 189 while (1) {
191 //printconnection(0); 190 //printconnection(0);
192 Lossless_UDP(); 191 networking_poll(ludp->net);
192 do_lossless_udp(ludp);
193 193
194 if (is_connected(connection) >= 2) { 194 if (is_connected(ludp, connection) >= 2) {
195 kill_connection_in(connection, 3000000); 195 kill_connection_in(ludp, connection, 3000000);
196 read = read_packet(connection, buffer); 196 read = read_packet(ludp, connection, buffer);
197 197
198 if (read != 0) { 198 if (read != 0) {
199 // printf("Received data.\n"); 199 // printf("Received data.\n");
@@ -202,7 +202,7 @@ int main(int argc, char *argv[])
202 } 202 }
203 } 203 }
204 204
205 if (is_connected(connection) == 4) { 205 if (is_connected(ludp, connection) == 4) {
206 printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer)); 206 printf("Connecting Lost after: %llu us\n", (unsigned long long)(current_time() - timer));
207 fclose(file); 207 fclose(file);
208 return 1; 208 return 1;