Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::net::UDPSocket Class Reference

A UDP socket. More...

#include <udp.h>

Inheritance diagram for MaxOS::net::UDPSocket:
MaxOS::common::EventManager< UDPEvents >

Public Member Functions

 UDPSocket ()
 Socket
 
virtual void handle_user_datagram_protocol_payload (uint8_t *data, uint16_t size)
 Handle the recivement of a UDP payload.
 
virtual void send (uint8_t *data, uint16_t size)
 send data through the UDP socket
 
virtual void disconnect ()
 disconnect the UDP socket
 
- Public Member Functions inherited from MaxOS::common::EventManager< UDPEvents >
void connect_event_handler (EventHandler< UDPEvents > *handler)
 connect an event handler to the event manager if it is not already connected
 
void disconnect_event_handler (EventHandler< UDPEvents > *handler)
 disconnect an event handler from the event manager if it is connected
 
Vector< Event< UDPEvents > * > raise_event (Event< UDPEvents > *event)
 Calls the on_event function of all the event m_handlers connected to the event manager and returns a list of the results.
 

Protected Attributes

bool listening
 Wether the port is waiting for incoming connections.
 
uint16_t local_port = 0
 The port on this device.
 
uint16_t remote_port = 0
 The port on the remote device.
 
uint32_t local_ip = 0
 The IP of this device.
 
uint32_t remote_ip = 0
 The IP of the remote device.
 
UserDatagramProtocolHandleruser_datagram_protocol_handler
 The UDP handler this socket is connected to.
 
- Protected Attributes inherited from MaxOS::common::EventManager< UDPEvents >
Vector< EventHandler< UDPEvents > * > m_handlers
 

Friends

class UserDatagramProtocolHandler
 

Detailed Description

A UDP socket.

Definition at line 85 of file udp.h.

Constructor & Destructor Documentation

◆ UDPSocket()

UDPSocket::UDPSocket ( )

Socket

Definition at line 57 of file udp.cpp.

57 {
58
59 //Set the instance variables
60 listening = false;
61
62}
bool listening
Wether the port is waiting for incoming connections.
Definition udp.h:89

References listening.

Member Function Documentation

◆ disconnect()

void UDPSocket::disconnect ( )
virtual

disconnect the UDP socket

Definition at line 96 of file udp.cpp.

96 {
97
99
100}
UserDatagramProtocolHandler * user_datagram_protocol_handler
The UDP handler this socket is connected to.
Definition udp.h:97
void disconnect(UDPSocket *socket)
Disconnects the socket from the remote IP and port.
Definition udp.cpp:248

References MaxOS::net::UserDatagramProtocolHandler::disconnect(), and user_datagram_protocol_handler.

◆ handle_user_datagram_protocol_payload()

void UDPSocket::handle_user_datagram_protocol_payload ( uint8_t data,
uint16_t  size 
)
virtual

Handle the recivement of a UDP payload.

Parameters
dataThe data received
sizeThe size of the data received

Definition at line 72 of file udp.cpp.

72 {
73
74 // Create the event
75 auto* event = new UDPDataReceivedEvent(this, data, size);
78
79}
Vector< Event< UDPEvents > * > raise_event(Event< UDPEvents > *event)
Calls the on_event function of all the event m_handlers connected to the event manager and returns a ...
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
static void kfree(void *pointer)
Frees a block of memory using the kernel memory manager.
Event fired when data is received on a UDP socket.
Definition udp.h:56

References MaxOS::memory::MemoryManager::kfree(), and MaxOS::common::EventManager< UDPEvents >::raise_event().

Referenced by MaxOS::net::UserDatagramProtocolHandler::handle_internet_protocol_payload().

◆ send()

void UDPSocket::send ( uint8_t data,
uint16_t  size 
)
virtual

send data through the UDP socket

Parameters
dataThe data to send
sizeThe size of the data

Definition at line 87 of file udp.cpp.

87 {
88
89 user_datagram_protocol_handler->send(this, data, size);
90
91}
void send(UDPSocket *socket, const uint8_t *data, uint16_t size)
Sends a packet to the remote IP and port.
Definition udp.cpp:269

References MaxOS::net::UserDatagramProtocolHandler::send(), and user_datagram_protocol_handler.

Friends And Related Symbol Documentation

◆ UserDatagramProtocolHandler

friend class UserDatagramProtocolHandler
friend

Definition at line 86 of file udp.h.

Member Data Documentation

◆ listening

bool MaxOS::net::UDPSocket::listening
protected

Wether the port is waiting for incoming connections.

Definition at line 89 of file udp.h.

Referenced by MaxOS::net::UserDatagramProtocolHandler::handle_internet_protocol_payload(), and UDPSocket().

◆ local_ip

uint32_t MaxOS::net::UDPSocket::local_ip = 0
protected

The IP of this device.

Definition at line 94 of file udp.h.

◆ local_port

uint16_t MaxOS::net::UDPSocket::local_port = 0
protected

The port on this device.

Definition at line 91 of file udp.h.

◆ remote_ip

uint32_t MaxOS::net::UDPSocket::remote_ip = 0
protected

◆ remote_port

uint16_t MaxOS::net::UDPSocket::remote_port = 0
protected

The port on the remote device.

Definition at line 92 of file udp.h.

Referenced by MaxOS::net::UserDatagramProtocolHandler::handle_internet_protocol_payload().

◆ user_datagram_protocol_handler

UserDatagramProtocolHandler* MaxOS::net::UDPSocket::user_datagram_protocol_handler
protected

The UDP handler this socket is connected to.

Definition at line 97 of file udp.h.

Referenced by disconnect(), and send().


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