You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
1.3 KiB

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <inttypes.h>
struct message_t {
uint32_t addr;
size_t length;
void *data_p;
};
struct subscription_t {
uint32_t addr;
int fd_listen, fd_client;
};
struct list_subscription_cell_t {
struct subscription_t subscription;
struct list_subscription_cell_t *prev_p, *next_p;
};
struct list_subscription_t {
struct list_subscription_cell_t *list_p, *read_p;
int fd_command_listen, fd_command_client;
};
int char_hexa_to_uint32(const char *const argv, uint32_t *nombre);
/* initialise la liste en mettant le port port_listen en écoute pour recevoir les commandes «subscribe» et «unsubscribe» */
int list_subscription_init(struct list_subscription_t *list_p, int port_listen);
/* détruit la liste */
void list_subscription_destroy(struct list_subscription_t *list_p);
/* envoyer le message (retourne 0 si l'adresse de destination du message n'est pas incrite) */
int send_message(struct list_subscription_t *list_p, struct message_t *message_p);
/* fonction qui fait un malloc de message_p->data */
int read_message(struct list_subscription_t *list_p, struct message_t *message_p);