YARP
Yet Another Robot Platform
os/simple_receiver.cpp

This reads some data from a port.Designed to be used with os/simple_sender.cpp example.

/*
* Copyright (C) 2006-2020 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 <stdio.h>
using namespace yarp::os;
int main() {
Bottle bot;
Port input;
input.open("/receiver");
// usually, we create connections externally, but just for this example...
Network::connect("/sender","/receiver");
input.read(bot);
printf("Got message: %s\n", bot.toString().c_str());
input.close();
return 0;
}
yarp::os::Port::close
void close() override
Stop port activity.
Definition: Port.cpp:356
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:72
yarp::os::Bottle::toString
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition: Bottle.cpp:214
Network.h
Port.h
main
int main(int argc, char *argv[])
Definition: yarpros.cpp:259
yarp::os::Port::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: Port.cpp:81
yarp::os::Port
Definition: Port.h:49
yarp::os::NetworkBase::connect
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
Definition: Network.cpp:684
yarp::os::Port::read
bool read(PortReader &reader, bool willReply=false) override
Read an object from the port.
Definition: Port.cpp:474
yarp::os
Definition: AbstractCarrier.h:17
yarp::os::Network
Definition: Network.h:781
yarp
Definition: numeric.h:47
Bottle.h