From 457feeed0b49a83b8244d0046e0daf3a632fc092 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 27 Jun 2013 20:59:16 -0400 Subject: Added current work on Lossless_UDP (Not done do not test it yet) Lossless_UDP code is probably filled with problems right now. this is normal. --- core/Lossless_UDP.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 core/Lossless_UDP.h (limited to 'core/Lossless_UDP.h') diff --git a/core/Lossless_UDP.h b/core/Lossless_UDP.h new file mode 100644 index 00000000..38b41309 --- /dev/null +++ b/core/Lossless_UDP.h @@ -0,0 +1,58 @@ +/* Lossless_UDP.h +* +* An implementation of the Lossless_UDP protocol as seen in docs/Lossless_UDP.txt +* +*/ +#ifndef LOSSLESS_UDP_H +#define LOSSLESS_UDP_H + +#include "network.h" + + + + +//Functions + +//initialize a new connection to ip_port +//returns an integer corresponding to the connection id. +//return -1 if it could not initialize the connection. +int new_connection(IP_Port ip_port); + +//returns an integer corresponding to the next connection in our imcoming connection list +//return -1 if there are no new incoming connections in the list. +int incoming_connection(); + +//return -1 if it could not kill the connection. +//return 0 if killed successfully +int kill_connection(int connection_id); + +//return 0 if there is no received data in the buffer. +//return length of recieved packet if successful +int read_packet(int connection_id, char * data); + +//return 0 if data could not be put in packet queue +//return 1 if data was put into the queue +int write_packet(int connection_id, char * data, uint32_t length); + +//returns the number of packets in the queue waiting to be successfully sent. +int sendqueue(int connection_id); + +//returns the number of packets in the queue waiting to be successfully read with read_packet(...) +int recvqueue(int connection_id); + +//check if connection is connected +//return 0 no. +//return 1 if yes +//return 2 if the initial attempt isn't over yet. +int is_connected(int connection_id); + +//Call this function a couple times per second +//It's the main loop. +void doLossless_UDP(); + +//if we receive a Lossless_UDP packet we call this function so it can be handled. +//Return 0 if packet is handled correctly. +//return 1 if it didn't handle the packet or if the packet was shit. +int LosslessUDP_handlepacket(char * packet, uint32_t length, IP_Port source); + +#endif \ No newline at end of file -- cgit v1.2.3