friendev EtherDune TCP/IP library
Public Member Functions | Protected Member Functions | List of all members
UDPSocket Class Reference

Implements the UDP protocol. More...

#include <UDPSocket.h>

Inheritance diagram for UDPSocket:
Socket NetworkService ListItem ENC28J60 DHCP DNSClient

Public Member Functions

 UDPSocket ()
 
bool send ()
 Sends the packet currently in the outgoing buffer More...
 
virtual void onReceive (uint16_t len)
 Called when a datagram has arrived. More...
 
- Public Member Functions inherited from Socket
uint16_t write (uint16_t len, const byte *data)
 In the case of TCP, writes the given data buffer to the socket. More...
 
uint16_t write (const String &s)
 In the case of TCP, writes the given String to the socket, not including the null-terminating character. More...
 
uint16_t write (const __FlashStringHelper *pattern,...)
 Writes out the specified PROGMEM string that may contain the % escape character. More...
 
template<class T >
uint16_t write (const T &message)
 Writes out the binary representation of the parameter to the socket. More...
 

Protected Member Functions

void prepareUDPPacket (uint16_t dataLength, uint16_t dataChecksum)
 Fills out the UDP header and calculates the datagram checksum More...
 
virtual bool sendPacket ()
 Sends the packet currently in the shared buffer More...
 
void tick ()
 This is a timer function that is called every NETWORK_TIMER_RESOLUTION milliseconds on every service. More...
 
- Protected Member Functions inherited from Socket
void prepareIPPacket ()
 
- Protected Member Functions inherited from NetworkService
 NetworkService ()
 
 ~NetworkService ()
 
virtual void onDNSResolve (uint8_t status, uint16_t identification, const IPAddress &ip)
 Called on each network service every time a DNS response is received. More...
 

Additional Inherited Members

- Public Attributes inherited from Socket
nint16_t remotePort
 remote TCP or UDP port More...
 
nint16_t localPort
 local TCP or UDP port More...
 
IPAddress remoteIP
 remote IP address to connect to (TCP) or send the next packet to (UDP) More...
 
- Static Protected Member Functions inherited from Socket
static uint16_t calcPseudoHeaderChecksum (uint8_t protocol, uint16_t length)
 Calculates the TCP or UDP pseudo header checksum. More...
 
static uint16_t calcTCPChecksum (bool options, uint16_t dataLength, uint16_t dataChecksum)
 Calculates the TCP checksum. More...
 
static uint16_t calcUDPChecksum (uint16_t dataLength, uint16_t dataChecksum)
 Calculates the UDP checksum. More...
 
static bool verifyUDPTCPChecksum ()
 Verifies if the UDP or TCP checksum of the current packet is correct. More...
 
- Static Protected Member Functions inherited from NetworkService
static bool sendIPPacket (uint16_t length)
 Puts the current in-memory packet in the network More...
 
static void prepareIPPacket (const IPAddress &remoteIP)
 Sets up common IP header values for all outgoing IP packets and calculates the IP header checksum More...
 
static bool sameLAN (IPAddress &dst)
 Determines whether the given IP is in the same subnet as localIP More...
 
static bool begin (uint8_t cspin)
 Initializes EtherDune and the underlying hardware More...
 
static void loop ()
 Gives processing time to EtherDune so that it can check for incoming packets or send queued packets. More...
 
static DNSClientDNS ()
 Obtains access to the DNS service singleton instance. More...
 
- Static Protected Member Functions inherited from ENC28J60
static void writeByte (byte b)
 
static void writeByte (uint16_t dst, byte b)
 
static void writeBuf (uint16_t dst, uint16_t len, const byte *data)
 
static void writeBuf (uint16_t len, const byte *data)
 
static uint16_t hardwareChecksum (uint16_t src, uint16_t len)
 
static uint16_t hardwareChecksumRxOffset (uint16_t offset, uint16_t len)
 
static void moveMem (uint16_t dest, uint16_t src, uint16_t len)
 
static void readBuf (uint16_t src, uint16_t len, byte *data)
 
static void readBuf (uint16_t len, byte *data)
 
static byte readByte (uint16_t src)
 
static void packetSend (uint16_t len)
 
static void packetSend (uint16_t len, const byte *data)
 
static void loadSample ()
 
static void loadAll ()
 
static void release ()
 
static uint8_t begin (uint8_t cspin)
 
static void loop ()
 
static void enableBroadcast ()
 
static bool isLinkUp ()
 Determines whether the network link is ready More...
 
- Protected Attributes inherited from Socket
SharedBuffer buffer
 output buffer for this socket More...
 
- Static Protected Attributes inherited from Socket
static uint8_t srcPort_L_count = 0
 self-incrementing counter for local ports. More...
 
- Static Protected Attributes inherited from NetworkService
static EthBuffer packet
 in-memory packet buffer currently being processed. More...
 
static ARPService ARP
 ARP singleton instance. More...
 
static MACAddress localMAC
 Ethernet MAC address. More...
 
static IPAddress localIP = { 0, 0, 0, 0 }
 IP address of this application. More...
 
static IPAddress gatewayIP = { 0, 0, 0, 0 }
 IP address of the gateway in this network. More...
 
static IPAddress netmask = { 0, 0, 0, 0 }
 Subnet mask. More...
 
static IPAddress dnsIP = { 0, 0, 0, 0 }
 IP address of the DNS server to use. More...
 

Detailed Description

Implements the UDP protocol.

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.

Definition at line 34 of file UDPSocket.h.

Constructor & Destructor Documentation

UDPSocket::UDPSocket ( )

Definition at line 31 of file UDPSocket.cpp.

Member Function Documentation

void UDPSocket::onReceive ( uint16_t  len)
virtual

Called when a datagram has arrived.

The data is at packet.udpData

Parameters
lenlength of the datagram

Definition at line 28 of file UDPSocket.cpp.

void UDPSocket::prepareUDPPacket ( uint16_t  dataLength,
uint16_t  dataChecksum 
)
protected

Fills out the UDP header and calculates the datagram checksum

Parameters
dataLengthLength of the data payload.
dataChecksumChecksum of the payload.

Definition at line 62 of file UDPSocket.cpp.

bool UDPSocket::send ( )

Sends the packet currently in the outgoing buffer

Returns

Definition at line 45 of file UDPSocket.cpp.

bool UDPSocket::sendPacket ( )
protectedvirtual

Sends the packet currently in the shared buffer

Returns

Definition at line 81 of file UDPSocket.cpp.

void UDPSocket::tick ( )
protectedvirtual

This is a timer function that is called every NETWORK_TIMER_RESOLUTION milliseconds on every service.

It allows each network service to perform upkeep tasks, handle timeouts or send queued messages.

Reimplemented from NetworkService.

Definition at line 99 of file UDPSocket.cpp.


The documentation for this class was generated from the following files: