UDP¶
Types¶
Name | Type | Description |
---|---|---|
mira_net_udp_connection_t |
struct |
|
mira_net_udp_callback_t |
void(* )(mira_net_udp_connection_t *connection, const void *data, uint16_t data_len, const mira_net_udp_callback_metadata_t *metadata, void *storage) |
Structs¶
mira_net_udp_callback_metadata_t¶
Type | Name | Description |
---|---|---|
mira_net_address_t |
source_address | |
mira_net_address_t |
destination_address | |
uint16_t |
source_port | |
uint16_t |
destination_port |
Functions¶
mira_net_udp_listen¶
mira_net_udp_connection_t* mira_net_udp_listen( uint16_t port, mira_net_udp_callback_t callback, void* storage);
Parameters
Parameter | Description |
---|---|
port |
The port number |
callback |
Callback function with data |
storage |
Storage pointer |
Return
A UDP connection on the specified port
mira_net_udp_connect¶
mira_net_udp_connection_t* mira_net_udp_connect( const mira_net_address_t* address, uint16_t port, mira_net_udp_callback_t callback, void* storage);
Parameters
Parameter | Description |
---|---|
address |
The IP address to connect to |
port |
The port number to connect to |
callback |
UDP callback function |
storage |
Storage pointer |
Return
UDP connection
mira_net_udp_bind¶
mira_net_udp_connection_t* mira_net_udp_bind( const mira_net_address_t* address, uint16_t remote_port, uint16_t local_port, mira_net_udp_callback_t callback, void* storage);
Parameters
Parameter | Description |
---|---|
address |
IP address to bind to |
remote_port |
The remote port to connect to |
local_port |
The local port to bind the connection to |
callback |
UDP callback function |
storage |
Storage pointer |
Return
The UDP Connection
mira_net_udp_close¶
mira_status_t mira_net_udp_close( mira_net_udp_connection_t* mira_udp_connection);
Parameters
Parameter | Description |
---|---|
mira_udp_connection |
The UDP connection to close |
Return
Status code indicating whether the operation was successful
mira_net_udp_send¶
mira_status_t mira_net_udp_send( mira_net_udp_connection_t* mira_udp_connection, const void* data, uint16_t data_len);
Parameters
Parameter | Description |
---|---|
mira_udp_connection |
The UDP connection over which the transmission should be made |
data |
The data to be sent |
data_len |
The length, in bytes, of the data to be sent |
Return
Status code indicating whether the operation was successful
mira_net_udp_send_to¶
mira_status_t mira_net_udp_send_to( mira_net_udp_connection_t* mira_udp_connection, const mira_net_address_t* address, uint16_t port, const void* data, uint16_t data_len);
Parameters
Parameter | Description |
---|---|
mira_udp_connection |
The UDP connection use for the transmission |
address |
The IP address to send to, i.e. the receiver |
port |
The UDP port to send to |
data |
Data to send as vector |
data_len |
The length of the data vector to send |
Return
Status code indicating whether the operation was successful