-
Notifications
You must be signed in to change notification settings - Fork 0
/
UDPSocket.h
66 lines (41 loc) · 1.31 KB
/
UDPSocket.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
59
60
61
62
63
64
65
66
// EtherDune UDP implementation as a NetworkService
// Author: Javier Peletier <[email protected]>
// Summary: Implements the UDP protocol
//
// Copyright (c) 2015 All Rights Reserved, http://friendev.com
//
// This source is subject to the GPLv2 license.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
/**
\class UDPSocket
\brief Implements the UDP protocol
\details This class implements the UDP protocol as a NetworkService.
To consume this class, create a derived class of UDPSocket to be able to override
the different virtual functions that notify of events related to the socket.
The socket write functions are inherited from Socket. Check out Socket::write()
for more information.
*/
#ifndef __UDPSOCKET_H_
#define __UDPSOCKET_H_
#include "Socket.h"
class UDPSocket : public Socket
{
private:
bool onPacketReceived();
bool sending;
protected:
void prepareUDPPacket(uint16_t dataLength, uint16_t dataChecksum);
virtual bool sendPacket();
void tick();
public:
UDPSocket();
bool send();
virtual void onReceive(uint16_t len);
};
#endif