summaryrefslogtreecommitdiff
path: root/src/IPC.cpp
diff options
context:
space:
mode:
authorBossCode45 <human.cyborg42@gmail.com>2024-11-26 15:21:56 +1300
committerBossCode45 <human.cyborg42@gmail.com>2024-11-26 15:21:56 +1300
commit72300460c1c1fa294cc4d1f1026d203a5adf4d28 (patch)
treebabbfba0ca2c9994609238b49e281476660a356d /src/IPC.cpp
parent8b48a9cfc4b0795a62a515e2519e7194d1d57347 (diff)
downloadYATwm-72300460c1c1fa294cc4d1f1026d203a5adf4d28.tar.gz
YATwm-72300460c1c1fa294cc4d1f1026d203a5adf4d28.zip
feat: Added a program (YATmsg) to communicate with YATwm
Currently just sends a hello message and nothing else, more to come later
Diffstat (limited to 'src/IPC.cpp')
-rw-r--r--src/IPC.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/IPC.cpp b/src/IPC.cpp
index 0aed97e..09bf78e 100644
--- a/src/IPC.cpp
+++ b/src/IPC.cpp
@@ -16,6 +16,10 @@ IPCModule::IPCModule(CommandsModule& commandsModule, Config& cfg, Globals& globa
cfg(cfg),
globals(globals)
{
+}
+
+void IPCModule::init()
+{
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
address.sun_family = AF_UNIX;
strcpy(address.sun_path, path);
@@ -27,15 +31,14 @@ IPCModule::IPCModule(CommandsModule& commandsModule, Config& cfg, Globals& globa
cout << "ERROR " << errno << endl;
}
cout << "SOCKETED" << endl;
-}
-
-void IPCModule::init()
-{
setIPCPath((unsigned char*)path, strlen(path));
+ ready = true;
}
void IPCModule::doListen()
{
+ if(!ready)
+ return;
if(listen(sockfd, 1) != 0)
{
cout << "ERROR 2" << endl;
@@ -75,11 +78,16 @@ void IPCModule::doListen()
void IPCModule::quitIPC()
{
+ if(!ready)
+ return;
close(sockfd);
+ ready = false;
}
int IPCModule::getFD()
{
+ if(!ready)
+ return -1;
if(sockfd > 0)
return sockfd;
return -1;