7 volatile bool bar_reachable = false;
9 void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
10 if(!strcmp(node->name, "bar"))
11 bar_reachable = reachable;
14 int main(int argc, char *argv[]) {
15 // Open two new meshlink instance.
17 meshlink_handle_t *mesh1 = meshlink_open("import_export_conf.1", "foo");
21 meshlink_handle_t *mesh2 = meshlink_open("import_export_conf.2", "bar");
25 // Import and export both side's data
27 meshlink_add_address(mesh1, "localhost");
28 meshlink_add_address(mesh2, "localhost");
30 char *data = meshlink_export(mesh1);
32 if(!meshlink_import(mesh2, data))
37 data = meshlink_export(mesh2);
39 if(!meshlink_import(mesh1, data))
44 // Start both instances
46 meshlink_set_node_status_cb(mesh1, status_cb);
48 if(!meshlink_start(mesh1))
51 if(!meshlink_start(mesh2))
54 // Wait for the two to connect.
56 for(int i = 0; i < 20; i++) {
69 meshlink_close(mesh2);
70 meshlink_close(mesh1);