YARP
Yet Another Robot Platform
os/simple_sender.cpp

This outputs some data to a port.Designed to be used with os/simple_receiver.cpp example.

/*
* Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
* Copyright (C) 2006-2010 RobotCub Consortium
* All rights reserved.
*
* This software may be modified and distributed under the terms of the
* BSD-3-Clause license. See the accompanying LICENSE file for details.
*/
#include <yarp/os/Port.h>
#include <yarp/os/Bottle.h>
#include <yarp/os/Time.h>
#include <stdio.h>
using namespace yarp::os;
int main() {
Port output;
output.open("/sender");
int top = 100;
for (int i=1; i<=top; i++) {
// prepare a message
Bottle bot;
bot.addString("testing");
bot.addInt32(i);
bot.addString("of");
bot.addInt32(top);
// send the message
output.write(bot);
printf("Sent message: %s\n", bot.toString().c_str());
// wait a while
}
output.close();
return 0;
}