You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
862 B
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "MyService.h"
#include "MyService.skeleton.h"
#include "rpc/IpcPipeChannel.h"
#include <sys/stat.h>
int main() {
// Создание FIFO — часть пользовательского IPCкода.
mkfifo("/tmp/fifo_to_server", 0666);
mkfifo("/tmp/fifo_to_client", 0666);
// IPCуровень: канал поверх pipe.
// Сервер читает из fifo_to_server и пишет в fifo_to_client.
IpcPipeChannel ch("/tmp/fifo_to_server", "/tmp/fifo_to_client");
// RPCуровень: скелет поверх того же канала.
MyService realObj;
MyServiceSkeleton skeleton(realObj);
while (true) {
IpcMessage req = ch.receive();
if (req.empty()) {
break;
}
IpcMessage resp = skeleton.dispatch(req);
ch.send(resp);
}
}