From c879d49c31f54dd9b98042f0c80c2ec73d6835e1 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Tue, 8 Oct 2019 13:54:23 +0200 Subject: [PATCH] IPC version 0.3, allow multiple messages at once --- examples/pongd.c | 4 +++- project.zsh | 2 +- src/ipc.h | 2 +- src/usocket.c | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/pongd.c b/examples/pongd.c index 1fe47b6..543a8ea 100644 --- a/examples/pongd.c +++ b/examples/pongd.c @@ -73,11 +73,13 @@ void main_loop () struct ipc_message *m = event.m; #ifdef PONGD_VERBOSE if (m->length > 0) { - printf ("message received (type %d, user type %d, size %u bytes): %.*s\n", m->type, m->user_type, m->length, m->length, m->payload); + printf ("message received (type %d, user type %d, size %u bytes): %.*s\n" + , m->type, m->user_type, m->length, m->length, m->payload); } else { printf ("message with a 0-byte size :(\n"); } + #endif ret = ipc_write (event.origin, m); diff --git a/project.zsh b/project.zsh index 0c336e1..ce7d365 100644 --- a/project.zsh +++ b/project.zsh @@ -1,6 +1,6 @@ package=ipc -version=0.1.0 +version=0.3.0 CFLAGS="-Wall -Wextra -g" diff --git a/src/ipc.h b/src/ipc.h index 6ca0701..3f069f2 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -18,7 +18,7 @@ #define IPC_HEADER_SIZE 6 #define IPC_MAX_MESSAGE_SIZE 8000000-IPC_HEADER_SIZE -#define IPC_VERSION 2 +#define IPC_VERSION 3 #if ! defined(IPC_WITHOUT_ERRORS) && ! defined(IPC_WITH_ERRORS) #define IPC_WITH_ERRORS 2 diff --git a/src/usocket.c b/src/usocket.c index 8f65ea1..b97439f 100644 --- a/src/usocket.c +++ b/src/usocket.c @@ -158,7 +158,7 @@ enum ipc_errors usock_connect (int32_t *fd, const char *path) int32_t sfd; socklen_t peer_addr_size = sizeof(struct sockaddr_un); - T_PERROR_R (((sfd = socket (AF_UNIX, SOCK_STREAM, 0)) == -1), "socket", IPC_ERROR_USOCK_CONNECT__SOCKET); + T_PERROR_R (((sfd = socket (AF_UNIX, SOCK_SEQPACKET, 0)) == -1), "socket", IPC_ERROR_USOCK_CONNECT__SOCKET); strncpy(my_addr.sun_path, path, (strlen (path) < PATH_MAX) ? strlen(path) : PATH_MAX); /** TODO: massive series of tests */ @@ -185,7 +185,7 @@ enum ipc_errors usock_init (int32_t *fd, const char *path) int32_t sfd; socklen_t peer_addr_size; - T_PERROR_R (((sfd = socket (AF_UNIX, SOCK_STREAM, 0)) == -1), "socket", IPC_ERROR_USOCK_INIT__WRONG_FILE_DESCRIPTOR); + T_PERROR_R (((sfd = socket (AF_UNIX, SOCK_SEQPACKET, 0)) == -1), "socket", IPC_ERROR_USOCK_INIT__WRONG_FILE_DESCRIPTOR); // delete the unix socket if already created // ignore otherwise