Obsolete
/
libipc-old
Archived
3
0
Fork 0

IPC version 0.3, allow multiple messages at once

more_to_read
Philippe PITTOLI 2019-10-08 13:54:23 +02:00
parent f8bc00e03a
commit c879d49c31
4 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -1,6 +1,6 @@
package=ipc
version=0.1.0
version=0.3.0
CFLAGS="-Wall -Wextra -g"

View File

@ -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

View File

@ -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