12#define MSG_TERMINATOR '|'
14#pragma region LOW LEVEL
62#pragma region HIGH LEVEL
92int read_messages(
int bytes_received,
char *msg_buffer,
void * p);
130void add_message_handler(
void *
peer,
char *msg,
int (*callback)(
int,
char *,
void *,
void **),
int lifespan,
int argc,
void **data);
int socket_request_receive(struct socket_request_listener *listener, int client_sock, char *buffer, int size, int timeout, int flags)
Receives a socket request.
Definition network_utils.c:65
int send_message(int socket, const char *message, int flags)
Sends a message through a socket.
Definition network_utils.c:164
struct socket_request_listener create_socket_request_listener(int sock)
Creates a socket request listener.
Definition network_utils.c:28
int receive_message(void *peer, char **buffer, int size, int timeout, int flags)
Receives a message from a peer.
Definition network_utils.c:106
void add_message_handler(void *peer, char *msg, int(*callback)(int, char *, void *, void **), int lifespan, int argc, void **data)
Adds a message handler.
Definition network_utils.c:210
void remove_message_handler_by_index(void *p, int index)
Removes a message handler by its index.
Definition network_utils.c:189
int read_messages(int bytes_received, char *msg_buffer, void *p)
Reads messages from a buffer.
Definition network_utils.c:140
void close_socket(int sock)
Closes a socket.
Definition network_utils.c:20
int initiate_socket()
Initiates a socket.
Definition network_utils.c:9
struct peer * create_peer(int socket)
Creates a peer structure.
Definition network_utils.c:85
void remove_message_handling(void *p, char *msg)
Removes a message handler by its message.
Definition network_utils.c:200
int socket_request_listen(struct socket_request_listener *listener, int server_sock, int timeout)
Listens for socket requests.
Definition network_utils.c:39
Structure to represent a network peer.
Definition socket.h:64
int socket
Definition socket.h:65
Structure to hold socket request listener information.
Definition socket.h:31
struct timeval timeout
Definition socket.h:33