This example shows how to communicate between a pair of buffered ports.
#include <cstdio>
int main(
int argc,
char* argv[])
{
Network::setLocalMode(true);
BufferedPort<Bottle> in;
BufferedPort<Bottle> out;
in.setStrict();
in.open("/in");
out.open("/out");
Network::connect("/out", "/in");
Bottle& outBot1 = out.prepare();
outBot1.fromString("hello world");
printf("Writing bottle 1 (%s)\n", outBot1.toString().c_str());
out.write();
Bottle& outBot2 = out.prepare();
outBot2.fromString("2 3 5 7 11");
printf("Writing bottle 2 (%s)\n", outBot2.toString().c_str());
out.writeStrict();
Bottle* inBot1 = in.read();
printf("Bottle 1 is: %s\n", inBot1->toString().c_str());
Bottle* inBot2 = in.read();
printf("Bottle 2 is: %s\n", inBot2->toString().c_str());
return 0;
}