Mercurial > hg > beaglert
comparison include/UdpServer.h @ 44:f5b5c648cd5d ultra-staging
- added (unused) simple c++ classes for udp datagrams\n- added tests for the new classes
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Wed, 20 May 2015 18:07:16 +0100 |
parents | |
children | 2197435e8fb4 |
comparison
equal
deleted
inserted
replaced
42:24af9a14b203 | 44:f5b5c648cd5d |
---|---|
1 /* | |
2 * udpServer.h | |
3 * | |
4 * Created on: 19 May 2015 | |
5 * Author: giulio moro | |
6 */ | |
7 | |
8 #ifndef UDPSERVER_H_ | |
9 #define UDPSERVER_H_ | |
10 | |
11 #include <sys/types.h> | |
12 #include <sys/socket.h> | |
13 #include <netinet/in.h> | |
14 #include <arpa/inet.h> | |
15 #include <netdb.h> | |
16 #include <stdio.h> | |
17 #include <stdlib.h> | |
18 #include <unistd.h> | |
19 #include <string.h> | |
20 | |
21 class UdpServer{ | |
22 private: | |
23 int port; | |
24 int enabled; | |
25 int inSocket; | |
26 struct sockaddr_in server; | |
27 struct timeval stTimeOut; | |
28 fd_set stReadFDS; | |
29 int size; | |
30 void *wasteBuffer; | |
31 int wasteBufferSize; | |
32 int length; | |
33 socklen_t fromLength; | |
34 struct sockaddr_in from; | |
35 public: | |
36 UdpServer(); | |
37 UdpServer(int aPort); | |
38 ~UdpServer(); | |
39 bool init(int aPort); | |
40 bool bindToPort(int aPort); | |
41 int getBoundPort() const; | |
42 int read(void *destBuffer, | |
43 int maxBytesToRead); | |
44 int emptySocket(); | |
45 int emptySocket(int maxBytes); | |
46 void *getWaste(); | |
47 }; | |
48 | |
49 | |
50 | |
51 #endif /* UDPSERVER_H_ */ |