From 25e540fefc0a5100e75afb058a5fba21eb40623e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= <ecklm94@gmail.com> Date: Wed, 25 May 2016 18:21:21 +0200 Subject: [PATCH] =?UTF-8?q?IPC=20k=C3=A9sz=C3=BCl=20(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UNIX domain socket lesz, és mivel UDP wrappert már implementáltam, illetve UNIX socket használható datagram socketként, így akkor már ezt fogom használni (nem kell csomagszeparáció stb.). Csak itt még rá kell jönni, hogy hogyan küldjek üzenetet olyanra, amit már létrehoztak, illetve hogyan "kapcsolódjak" rá... --- include/IPC_US_communicator.h | 21 +++++++++++++++++++++ src/IPC_US_communicator.cpp | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 include/IPC_US_communicator.h create mode 100644 src/IPC_US_communicator.cpp diff --git a/include/IPC_US_communicator.h b/include/IPC_US_communicator.h new file mode 100644 index 0000000..774e7f6 --- /dev/null +++ b/include/IPC_US_communicator.h @@ -0,0 +1,21 @@ +/* + * File: IPC_US_communicator.h + * Author: Eckl Máté <ecklm94@gmail.com> + * + * Created on 2016. május 25., 18:09 + */ + +#ifndef IPC_US_COMMUNICATOR_H +#define IPC_US_COMMUNICATOR_H + +#include "udp_socket_wp.h" + +class IPC_US_communicator +{ + udp_socket_wp sock; + IPC_US_communicator(const IPC_US_communicator& orig); +public: + IPC_US_communicator(const char *socket_path); +}; + +#endif /* IPC_US_COMMUNICATOR_H */ diff --git a/src/IPC_US_communicator.cpp b/src/IPC_US_communicator.cpp new file mode 100644 index 0000000..ee2dfce --- /dev/null +++ b/src/IPC_US_communicator.cpp @@ -0,0 +1,20 @@ +/* + * File: IPC_US_communicator.cpp + * Author: Eckl Máté <ecklm94@gmail.com> + * + * Created on 2016. május 25., 18:09 + */ + +#include <sys/socket.h> +#include <sys/un.h> + +#include "../include/IPC_US_communicator.h" + +IPC_US_communicator::IPC_US_communicator(const char* socket_path) { + sockaddr_un ipc; + memset(&ipc, 0, sizeof(ipc)); + ipc.sun_family = AF_UNIX; + strncpy(ipc.sun_path+1, socket_path, sizeof(ipc.sun_path)-1-1); + sock.set_domain(AF_UNIX); + sock.bind_wp((sockaddr*) &ipc, sizeof(ipc)); +} -- GitLab