IPC version 0.3, allow multiple messages at once
parent
f8bc00e03a
commit
c879d49c31
|
@ -73,11 +73,13 @@ void main_loop ()
|
||||||
struct ipc_message *m = event.m;
|
struct ipc_message *m = event.m;
|
||||||
#ifdef PONGD_VERBOSE
|
#ifdef PONGD_VERBOSE
|
||||||
if (m->length > 0) {
|
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 {
|
else {
|
||||||
printf ("message with a 0-byte size :(\n");
|
printf ("message with a 0-byte size :(\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = ipc_write (event.origin, m);
|
ret = ipc_write (event.origin, m);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
package=ipc
|
package=ipc
|
||||||
version=0.1.0
|
version=0.3.0
|
||||||
|
|
||||||
CFLAGS="-Wall -Wextra -g"
|
CFLAGS="-Wall -Wextra -g"
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#define IPC_HEADER_SIZE 6
|
#define IPC_HEADER_SIZE 6
|
||||||
#define IPC_MAX_MESSAGE_SIZE 8000000-IPC_HEADER_SIZE
|
#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)
|
#if ! defined(IPC_WITHOUT_ERRORS) && ! defined(IPC_WITH_ERRORS)
|
||||||
#define IPC_WITH_ERRORS 2
|
#define IPC_WITH_ERRORS 2
|
||||||
|
|
|
@ -158,7 +158,7 @@ enum ipc_errors usock_connect (int32_t *fd, const char *path)
|
||||||
int32_t sfd;
|
int32_t sfd;
|
||||||
socklen_t peer_addr_size = sizeof(struct sockaddr_un);
|
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);
|
strncpy(my_addr.sun_path, path, (strlen (path) < PATH_MAX) ? strlen(path) : PATH_MAX);
|
||||||
|
|
||||||
/** TODO: massive series of tests */
|
/** TODO: massive series of tests */
|
||||||
|
@ -185,7 +185,7 @@ enum ipc_errors usock_init (int32_t *fd, const char *path)
|
||||||
int32_t sfd;
|
int32_t sfd;
|
||||||
socklen_t peer_addr_size;
|
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
|
// delete the unix socket if already created
|
||||||
// ignore otherwise
|
// ignore otherwise
|
||||||
|
|
Reference in New Issue