friendev EtherDune TCP/IP library
/home/jander/temp/etherdune/UDPSocket.h
Go to the documentation of this file.
1 // EtherDune UDP implementation as a NetworkService
2 // Author: Javier Peletier <jm@friendev.com>
3 // Summary: Implements the UDP protocol
4 //
5 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
6 //
7 // This source is subject to the GPLv2 license.
8 // Please see the License.txt file for more information.
9 // All other rights reserved.
10 //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14 // PARTICULAR PURPOSE.
15 
28 #ifndef __UDPSOCKET_H_
29 #define __UDPSOCKET_H_
30 
31 #include "Socket.h"
32 
33 
34 class UDPSocket : public Socket
35 {
36 
37 private:
38 
39  bool onPacketReceived();
40  bool sending;
41 
42 protected:
43 
44  void prepareUDPPacket(uint16_t dataLength, uint16_t dataChecksum);
45 
46  virtual bool sendPacket();
47  void tick();
48 
49 public:
50 
51  UDPSocket();
52 
53  bool send();
54 
55 
56  virtual void onReceive(uint16_t len);
57 
58 };
59 
60 
61 
62 
63 
64 
65 
66 #endif
virtual void onReceive(uint16_t len)
Called when a datagram has arrived.
Definition: UDPSocket.cpp:28
Implements the UDP protocol.
Definition: UDPSocket.h:34
void tick()
This is a timer function that is called every NETWORK_TIMER_RESOLUTION milliseconds on every service...
Definition: UDPSocket.cpp:99
bool send()
Sends the packet currently in the outgoing buffer
Definition: UDPSocket.cpp:45
void prepareUDPPacket(uint16_t dataLength, uint16_t dataChecksum)
Fills out the UDP header and calculates the datagram checksum
Definition: UDPSocket.cpp:62
Base class for TCP and UDP sockets.
Definition: Socket.h:37
virtual bool sendPacket()
Sends the packet currently in the shared buffer
Definition: UDPSocket.cpp:81