FreeRTOS Emulator with SDL2 Based Graphics and Input Library  1.0
A POSIX wrapper to run FreeRTOS on an x86 machine with some basic input and output libraries aimed at making teaching FreeRTOS simpler.
AIO Socket Examples

The AIO socket library works around opening a socket with an attached handler that is then asynchronously called when datta is put to the socket. More...

Macros

#define UDP_BUFFER_SIZE   2000
 
#define UDP_TEST_PORT_1   1234
 
#define UDP_TEST_PORT_2   4321
 
#define TCP_BUFFER_SIZE   2000
 
#define TCP_TEST_PORT   2222
 

Functions

int xCreateSocketTasks (void)
 Creates the UDP and TCP demo tasks used for demonstration purposes. More...
 
void vDeleteSocketTasks (void)
 Deletes the demo sockets tasks found in async_sockets.h. More...
 

Variables

TaskHandle_t UDPDemoTask
 
TaskHandle_t TCPDemoTask
 
aIO_handle_t udp_soc_one
 
aIO_handle_t udp_soc_two
 
aIO_handle_t tcp_soc
 

Detailed Description

The AIO socket library works around opening a socket with an attached handler that is then asynchronously called when datta is put to the socket.

Opening a socket

char *addr = NULL; // Loopback
in_port_t port = UDP_TEST_PORT_1;
aIO_handle_t aIOOpenUDPSocket(char *s_addr, in_port_t port, size_t buffer_size, void(*callback)(size_t, char *, void *), void *args)
Definition: AsyncIO.c:495
void vUDPHandlerOne(size_t read_size, char *buffer, void *args)
Definition: async_sockets.c:43
aIO_handle_t udp_soc_one
Definition: async_sockets.c:36
#define UDP_BUFFER_SIZE
Definition: async_sockets.h:64
#define UDP_TEST_PORT_1
Definition: async_sockets.h:65

Socket handler

void vTCPHandler(size_t read_size, char *buffer, void *args)
{
prints("TCP Recv: %s\n", buffer);
}
void vTCPHandler(size_t read_size, char *buffer, void *args)
Definition: async_sockets.c:143
void prints(const char *__format,...)
Prints a formatted string to stdout
Definition: gfx_print.c:104

Putting to socket

aIOSocketPut(UDP, NULL, UDP_TEST_PORT_1, test_str_1,
strlen(test_str_1));
int aIOSocketPut(aIO_socket_e protocol, char *s_addr, in_port_t port, char *buffer, size_t buffer_size)
Send the data stored in buffer to the socket described by s_addr and port.
Definition: AsyncIO.c:291
@ UDP
Definition: AsyncIO.h:58

Macro Definition Documentation

◆ TCP_BUFFER_SIZE

#define TCP_BUFFER_SIZE   2000

◆ TCP_TEST_PORT

#define TCP_TEST_PORT   2222

◆ UDP_BUFFER_SIZE

#define UDP_BUFFER_SIZE   2000

◆ UDP_TEST_PORT_1

#define UDP_TEST_PORT_1   1234

◆ UDP_TEST_PORT_2

#define UDP_TEST_PORT_2   4321

Function Documentation

◆ vDeleteSocketTasks()

void vDeleteSocketTasks ( void  )

Deletes the demo sockets tasks found in async_sockets.h.

◆ xCreateSocketTasks()

int xCreateSocketTasks ( void  )

Creates the UDP and TCP demo tasks used for demonstration purposes.

Returns
0 on success

Variable Documentation

◆ tcp_soc

aIO_handle_t tcp_soc
extern

◆ TCPDemoTask

TaskHandle_t TCPDemoTask
extern

◆ udp_soc_one

aIO_handle_t udp_soc_one
extern

◆ udp_soc_two

aIO_handle_t udp_soc_two
extern

◆ UDPDemoTask

TaskHandle_t UDPDemoTask
extern