#include <UdpConnection.h>

Inheritance diagram for UdpConnection:
Collaboration diagram for UdpConnection:

Public Member Functions

 UdpConnection ()
 
 UdpConnection (UdpConnectionDataDelegate dataHandler)
 
virtual ~UdpConnection ()
 
virtual bool listen (int port)
 
virtual bool connect (IpAddress ip, uint16_t port)
 
virtual void close ()
 
virtual bool send (const char *data, int length)
 
bool sendString (const char *data)
 
bool sendString (const String &data)
 
virtual bool sendTo (IpAddress remoteIP, uint16_t remotePort, const char *data, int length)
 
bool sendStringTo (IpAddress remoteIP, uint16_t remotePort, const char *data)
 
bool sendStringTo (IpAddress remoteIP, uint16_t remotePort, const String &data)
 
bool setMulticast (IpAddress ip)
 Sets the UDP multicast IP. More...
 
bool setMulticastTtl (size_t ttl)
 Sets the UDP multicast Time-To-Live(TTL). More...
 
- Public Member Functions inherited from IpConnection
bool joinMulticastGroup (IpAddress localIp, IpAddress multicastIp)
 Uses IGMP to add a local network interface to multicast group. More...
 
bool joinMulticastGroup (IpAddress multicastIp)
 Uses IGMP to add all local network interfaces to multicast group. More...
 
bool leaveMulticastGroup (IpAddress localIp, IpAddress multicastIp)
 Uses IGMP to remove a local network interface from multicast group. More...
 
bool leaveMulticastGroup (IpAddress multicastIp)
 Uses IGMP to remove all local network interfaces from multicast group. More...
 

Protected Member Functions

virtual void onReceive (pbuf *buf, IpAddress remoteIP, uint16_t remotePort)
 
bool initialize (udp_pcb *pcb=nullptr)
 

Static Protected Member Functions

static void staticOnReceive (void *arg, struct udp_pcb *pcb, struct pbuf *p, LWIP_IP_ADDR_T *addr, u16_t port)
 

Protected Attributes

udp_pcb * udp = nullptr
 
UdpConnectionDataDelegate onDataCallback = nullptr
 

Constructor & Destructor Documentation

◆ UdpConnection() [1/2]

UdpConnection::UdpConnection ( )
inline

◆ UdpConnection() [2/2]

UdpConnection::UdpConnection ( UdpConnectionDataDelegate  dataHandler)
inline

◆ ~UdpConnection()

virtual UdpConnection::~UdpConnection ( )
inlinevirtual

Member Function Documentation

◆ close()

virtual void UdpConnection::close ( )
virtual

◆ connect()

virtual bool UdpConnection::connect ( IpAddress  ip,
uint16_t  port 
)
virtual

◆ initialize()

bool UdpConnection::initialize ( udp_pcb *  pcb = nullptr)
protected

◆ listen()

virtual bool UdpConnection::listen ( int  port)
virtual

◆ onReceive()

virtual void UdpConnection::onReceive ( pbuf *  buf,
IpAddress  remoteIP,
uint16_t  remotePort 
)
protectedvirtual

Reimplemented in SSDP::Server, mDNS::Server, NtpClient, and DnsServer.

◆ send()

virtual bool UdpConnection::send ( const char *  data,
int  length 
)
virtual

◆ sendString() [1/2]

bool UdpConnection::sendString ( const char *  data)
inline

◆ sendString() [2/2]

bool UdpConnection::sendString ( const String data)
inline

◆ sendStringTo() [1/2]

bool UdpConnection::sendStringTo ( IpAddress  remoteIP,
uint16_t  remotePort,
const char *  data 
)
inline

◆ sendStringTo() [2/2]

bool UdpConnection::sendStringTo ( IpAddress  remoteIP,
uint16_t  remotePort,
const String data 
)
inline

◆ sendTo()

virtual bool UdpConnection::sendTo ( IpAddress  remoteIP,
uint16_t  remotePort,
const char *  data,
int  length 
)
virtual

◆ setMulticast()

bool UdpConnection::setMulticast ( IpAddress  ip)

Sets the UDP multicast IP.

Parameters
ip
Return values
truewhen LWIP supports this operation, false otherwise
Note
This method works only when LWIP is compiled with LWIP_MULTICAST_TX_OPTIONS

◆ setMulticastTtl()

bool UdpConnection::setMulticastTtl ( size_t  ttl)

Sets the UDP multicast Time-To-Live(TTL).

Parameters
ttl- time to live in hops. For example if a milticast UDP packet needs to pass through two routes to reach the receiver then the TTL should be set to 2
Return values
truewhen LWIP supports this operation, false otherwise
Note
This method works only when LWIP is compiled with LWIP_MULTICAST_TX_OPTIONS

◆ staticOnReceive()

static void UdpConnection::staticOnReceive ( void *  arg,
struct udp_pcb *  pcb,
struct pbuf *  p,
LWIP_IP_ADDR_T addr,
u16_t  port 
)
staticprotected

Member Data Documentation

◆ onDataCallback

UdpConnectionDataDelegate UdpConnection::onDataCallback = nullptr
protected

◆ udp

udp_pcb* UdpConnection::udp = nullptr
protected

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