1
0
Fork 0
mirror of https://gitlab.com/niansa/libhss.git synced 2025-03-06 20:49:21 +01:00

Updated example to make use of Bidirectional IPC

This commit is contained in:
niansa 2021-07-19 15:17:45 +02:00
parent 21fb69b630
commit 972526e88b
2 changed files with 4 additions and 2 deletions

View file

@ -9,8 +9,9 @@ void entry(QBiIPC& ipc) {
ipc.send("Hello world!"); ipc.send("Hello world!");
ipc.send_raw(size_t(1234567890)); ipc.send_raw(size_t(1234567890));
ipc.send("Trying to open file: /etc/passwd"); auto fname = ipc.recv();
std::ifstream f("/etc/passwd"); ipc.send("Trying to open file: "+fname);
std::ifstream f(fname);
if (f.fail()) { if (f.fail()) {
ipc.send(std::string("Failed: ")+strerror(errno)); ipc.send(std::string("Failed: ")+strerror(errno));
} else { } else {

View file

@ -13,6 +13,7 @@ int main() {
std::cout << ipc.recv() << std::endl std::cout << ipc.recv() << std::endl
<< ipc.recv_raw<size_t>() << std::endl; << ipc.recv_raw<size_t>() << std::endl;
ipc.send("/etc/passwd");
for (std::string line = ""; line != "End."; line = ipc.recv()) { for (std::string line = ""; line != "End."; line = ipc.recv()) {
if (!line.empty()) { if (!line.empty()) {
std::cout << line << std::endl; std::cout << line << std::endl;