63 return (i % 10 == 9) ? 2000000 :
static_cast<size_t>(i) * 1000;
68 return (i % 50 == 49) ? 500000 : 100;
74 for (
int i = 0; i < 20; ++i) {
85int main(
int argc,
char* argv[])
88 std::fprintf(
stderr,
"Usage: %s <normal|crash> <host> <rpc_port> <stream_port>\n", argv[0]);
92 const std::string
mode = argv[1];
93 const std::string host = argv[2];
94 const int rpc_port = std::atoi(argv[3]);
101 Network::setLocalMode(
true);
103 if (
mode ==
"crash") {
106 std::fprintf(
stderr,
"PEER: cannot connect\n");
118 if (
mode !=
"normal") {
119 std::fprintf(
stderr,
"PEER: unknown mode %s\n",
mode.c_str());
125 if (!client.
openFake(
"/shmem/xproc/peer/client") || !out.
openFake(
"/shmem/xproc/peer/out")) {
126 std::fprintf(
stderr,
"PEER: cannot open ports\n");
130 std::fprintf(
stderr,
"PEER: cannot connect\n");
141 cmd.
addString(std::string(len,
static_cast<char>(
'a' + i % 26)));
142 if (!client.
write(cmd, reply)
147 std::fprintf(
stderr,
"PEER: rpc %d failed\n", i);
157 std::fprintf(
stderr,
"PEER: stream write %d failed\n", i);
166 if (!client.
write(cmd, reply)) {
167 std::fprintf(
stderr,
"PEER: final rpc failed\n");
174 std::printf(
"PEER: %d failures\n",
failures);
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
Utilities for manipulating the YARP network, including initialization and shutdown.
A mini-server for network communication.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
bool openFake(const std::string &name)
Start port without making it accessible from the network.
void close() override
Stop port activity.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::string asString() const
Get string value.
void delay(double seconds)
Wait for a certain number of seconds.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.
int main(int argc, char *argv[])