FreeRTOS Tetris
|
A single file asyncronous UNIX communications library to perform UDP, TCP and POSIX message queue communications. More...
#include <mqueue.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <inttypes.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <pthread.h>
#include "AsyncIO.h"
Data Structures | |
struct | aIO_socket_t |
struct | aIO_mq_t |
struct | aIO_serial_t |
union | aIO_attr |
struct | aIO |
struct | aIO_tcp_client |
Macros | |
#define | _GNU_SOURCE |
#define | PRINT_CHECK |
Typedefs | |
typedef struct aIO | aIO_t |
Enumerations | |
enum | aIO_conn_e { NONE = 0, SOCKET, MSG_QUEUE, SERIAL, NO_OF_CONN_TYPES } |
Functions | |
void * | aIOTCPHandler (void *conn) |
aIO_t * | getLastConnection (void) |
static aIO_t * | findConnection (aIO_conn_e type, void *arg) |
void | aIOCloseConn (aIO_handle_t conn) |
Closes a connection and frees all resources used by that connection. More... | |
void | aIODeinit (void) |
Function that closes all open connections. More... | |
aIO_t * | createAsyncIO (aIO_conn_e type, size_t buffer_size, void(*callback)(size_t, char *, void *), void *args) |
static void | aIOMQSigHandler (union sigval sv) |
int | aIOMessageQueuePut (char *mq_name, char *buffer) |
Sends the data stored in buffer to the message queue with the provided name. More... | |
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. More... | |
aIO_handle_t | aIOOpenMessageQueue (char *name, long max_msg_num, long max_msg_size, void(*callback)(size_t, char *, void *), void *args) |
static void | aIOSocketSigHandler (int signal, siginfo_t *info, void *context) |
aIO_handle_t | aIOOpenUDPSocket (char *s_addr, in_port_t port, size_t buffer_size, void(*callback)(size_t, char *, void *), void *args) |
aIO_handle_t | aIOOpenTCPSocket (char *s_addr, in_port_t port, size_t buffer_size, void(*callback)(size_t, char *, void *), void *args) |
Variables | |
aIO_t | head = { .type = NONE, .lock = PTHREAD_MUTEX_INITIALIZER } |
pthread_cond_t | aIO_quit_conn = PTHREAD_COND_INITIALIZER |
pthread_mutex_t | aIO_quit_lock = PTHREAD_MUTEX_INITIALIZER |
A single file asyncronous UNIX communications library to perform UDP, TCP and POSIX message queue communications.
---------------------------------------------------------------------- Copyright (C) Alexander Hoffman, 2019 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ----------------------------------------------------------------------
#define PRINT_CHECK |
|
static |
reprime MQ notifications
aIO_handle_t aIOOpenMessageQueue | ( | char * | name, |
long | max_msg_num, | ||
long | max_msg_size, | ||
void(*)(size_t, char *, void *) | callback, | ||
void * | args | ||
) |
Attributes of MQ used in mq_open
sigval struct that is passed to handler. sival_ptr is used to pass pointer
to structure containing MQ information
Create MQ
sigevent needed to enable to passing of si_value to the handler
used by SIGEV_THREAD
aIO_handle_t aIOOpenTCPSocket | ( | char * | s_addr, |
in_port_t | port, | ||
size_t | buffer_size, | ||
void(*)(size_t, char *, void *) | callback, | ||
void * | args | ||
) |
Sprinkle a little reuseability on our shiny socket