4 #include "meshlink++.h"
8 int main(int argc, char *argv[]) {
9 // Open a new meshlink instance.
11 meshlink::mesh *mesh = meshlink::open("basicpp_conf", "foo");
13 cerr << "Could not initialize configuration for foo\n";
17 // Check that our own node exists.
19 meshlink::node *self = mesh->get_node("foo");
21 cerr << "Foo does not know about itself\n";
24 if(strcmp(self->name, "foo")) {
25 cerr << "Foo thinks its name is " << self->name << "\n";
29 // Start and stop the mesh.
32 cerr << "Foo could not start\n";
37 // Make sure we can start and stop the mesh again.
40 cerr << "Foo could not start twice\n";
45 // Close the mesh and open it again, now with a different name parameter.
47 meshlink::close(mesh);
49 // Check that the name is ignored now, and that we still are "foo".
51 mesh = meshlink::open("basic_conf", "bar");
53 cerr << "Could not open configuration for foo a second time\n";
57 if(mesh->get_node("bar")) {
58 cerr << "Foo knows about bar, it shouldn't\n";
62 self = mesh->get_node("foo");
64 cerr << "Foo doesn't know about itself the second time\n";
67 if(strcmp(self->name, "foo")) {
68 cerr << "Foo thinks its name is " << self->name << " the second time\n";
72 // Start and stop the mesh.
75 cerr << "Foo could not start a third time\n";
82 meshlink::close(mesh);