48 lines
942 B
C++
48 lines
942 B
C++
#include <chrono>
|
|
#include <cmath>
|
|
#include <thread>
|
|
|
|
#include <fmt/core.h>
|
|
|
|
#include "ipc/api.hpp"
|
|
|
|
int
|
|
main(int /* argc */, char** /* argv */)
|
|
{
|
|
using ipc::Ipc;
|
|
using fmt::format;
|
|
using fmt::print;
|
|
using namespace std::chrono_literals;
|
|
|
|
int verbose = 0;
|
|
ipc::init(); // default name
|
|
|
|
ipc::start_external("python test_server.py", true);
|
|
|
|
print("[client] pre-start\n");
|
|
auto client = Ipc(false, verbose);
|
|
print("[client] start\n");
|
|
|
|
double answer;
|
|
auto hline = "\n------------------------\n";
|
|
for (int i = 2; i <= 5; ++i) {
|
|
std::this_thread::sleep_for(500ms);
|
|
print(hline);
|
|
|
|
{
|
|
client.write(i);
|
|
print("[client] write int({})\n", i);
|
|
}
|
|
|
|
{
|
|
client.read(answer);
|
|
print("[client] read double({:.2e})\n", answer);
|
|
}
|
|
}
|
|
|
|
print(hline);
|
|
print("[client] finish the work\n\n");
|
|
|
|
return 0;
|
|
}
|