forked from andrewzk/Reliable-UDP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rudp_api.h
58 lines (48 loc) · 1.28 KB
/
rudp_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef RUDP_API_H
#define RUDP_API_H
#define RUDP_MAXPKTSIZE 1000 /* Number of data bytes that can sent in a
* packet, RUDP header not included */
/*
* Event types for callback notifications
*/
typedef enum {
RUDP_EVENT_TIMEOUT,
RUDP_EVENT_CLOSED,
} rudp_event_t;
/*
* RUDP socket handle
*/
typedef void *rudp_socket_t;
/*
* Prototypes
*/
/*
* Socket creation
*/
rudp_socket_t rudp_socket(int port);
/*
* Socket termination
*/
int rudp_close(rudp_socket_t rsocket);
/*
* Send a datagram
*/
int rudp_sendto(rudp_socket_t rsocket, void* data, int len,
struct sockaddr_in* to);
/*
* Register callback function for packet receiption
* Note: data and len arguments to callback function
* are only valid during the call to the handler
*/
int rudp_recvfrom_handler(rudp_socket_t rsocket,
int (*handler)(rudp_socket_t,
struct sockaddr_in *,
char *, int));
/*
* Register callback handler for event notifications
*/
int rudp_event_handler(rudp_socket_t rsocket,
int (*handler)(rudp_socket_t,
rudp_event_t,
struct sockaddr_in *));
#endif /* RUDP_API_H */