Open suvarchal opened 2 years ago
#include <libdill.h>
#include <stdio.h>
int main() {
// Connect to the IPC endpoint
int s = ipc_connect("/tmp/test.ipc", -1);
if (s < 0) {
perror("Error connecting to IPC endpoint");
return 1;
}
// Send data
int sent = bsend(s, "ABC", 3, -1);
if (sent < 0) {
perror("Error sending data");
ipc_close(s, -1);
return 1;
}
// Receive data
char buf[3];
int received = brecv(s, buf, sizeof(buf), -1);
if (received < 0) {
perror("Error receiving data");
ipc_close(s, -1);
return 1;
}
printf("Received data: %.*s\n", received, buf);
// Close the IPC connection
ipc_close(s, -1);
return 0;
}
Examples (at least) listed below should end with ipc_close(s, -1); http://libdill.org/ipc_connect.html http://libdill.org/ipc_close.html
example fix (just last line)