summaryrefslogtreecommitdiff
path: root/core/Lossless_UDP.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/Lossless_UDP.h')
-rw-r--r--core/Lossless_UDP.h58
1 files changed, 58 insertions, 0 deletions
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 @@
1/* Lossless_UDP.h
2*
3* An implementation of the Lossless_UDP protocol as seen in docs/Lossless_UDP.txt
4*
5*/
6#ifndef LOSSLESS_UDP_H
7#define LOSSLESS_UDP_H
8
9#include "network.h"
10
11
12
13
14//Functions
15
16//initialize a new connection to ip_port
17//returns an integer corresponding to the connection id.
18//return -1 if it could not initialize the connection.
19int new_connection(IP_Port ip_port);
20
21//returns an integer corresponding to the next connection in our imcoming connection list
22//return -1 if there are no new incoming connections in the list.
23int incoming_connection();
24
25//return -1 if it could not kill the connection.
26//return 0 if killed successfully
27int kill_connection(int connection_id);
28
29//return 0 if there is no received data in the buffer.
30//return length of recieved packet if successful
31int read_packet(int connection_id, char * data);
32
33//return 0 if data could not be put in packet queue
34//return 1 if data was put into the queue
35int write_packet(int connection_id, char * data, uint32_t length);
36
37//returns the number of packets in the queue waiting to be successfully sent.
38int sendqueue(int connection_id);
39
40//returns the number of packets in the queue waiting to be successfully read with read_packet(...)
41int recvqueue(int connection_id);
42
43//check if connection is connected
44//return 0 no.
45//return 1 if yes
46//return 2 if the initial attempt isn't over yet.
47int is_connected(int connection_id);
48
49//Call this function a couple times per second
50//It's the main loop.
51void doLossless_UDP();
52
53//if we receive a Lossless_UDP packet we call this function so it can be handled.
54//Return 0 if packet is handled correctly.
55//return 1 if it didn't handle the packet or if the packet was shit.
56int LosslessUDP_handlepacket(char * packet, uint32_t length, IP_Port source);
57
58#endif \ No newline at end of file