62 return "humans are handy";
66 const char *target =
"HUMANITY";
67 for (
size_t i=0; i<8 && i<header.
length(); i++) {
68 header.
get()[i] = target[i];
76 const char *target =
"HUMANITY";
77 for (
size_t i=0; i<8; i++) {
78 if (header.
get()[i] != target[i]) {
115 if (stream==NULL) {
return false; }
123 if (stream==NULL) {
return false; }
137 if (!ok)
return false;
143 std::string prefix =
"human says ";
144 Bytes b2((
char*)prefix.c_str(),prefix.length());
150 std::string prefix =
"human says ";
151 std::string compare = prefix;
152 Bytes b2((
char*)prefix.c_str(),prefix.length());
154 bool ok = proto.
is().
isOk() && (prefix==compare);
155 if (!ok) std::cout <<
"YOU DID NOT SAY 'human says '" << std::endl;
162 std::string prefix =
"computers rule!\r\n";
163 Bytes b2((
char*)prefix.c_str(),prefix.length());
169 std::string prefix =
"computers rule!\r\n";
170 std::string compare = prefix;
171 Bytes b2((
char*)prefix.c_str(),prefix.length());
173 bool ok = proto.
is().
isOk() && (prefix==compare);
174 if (!ok) std::cout <<
"YOU DID NOT SAY 'computers rule!'" << std::endl;
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
bool canAccept() const override
Check if reading is implemented for this carrier.
bool expectIndex(ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
void setParameters(const Bytes &header) override
Configure this carrier based on the first 8 bytes of the connection.
Carrier * create() const override
Factory method.
bool checkHeader(const Bytes &header) override
Given the first 8 bytes received on a connection, decide if this is the right carrier type to use for...
bool expectAck(ConnectionState &proto) override
Receive an acknowledgement, if expected for this carrier.
bool isConnectionless() const override
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
void getHeader(Bytes &header) const override
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
bool write(ConnectionState &proto, SizedWriter &writer) override
Write a message.
bool isLocal() const override
Check if carrier operates within a single process.
bool isActive() const override
Check if carrier is alive and error free.
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
bool expectSenderSpecifier(ConnectionState &proto) override
Expect the name of the sending port.
bool expectExtraHeader(ConnectionState &proto) override
Receive any carrier-specific header.
bool canOffer() const override
Check if writing is implemented for this carrier.
bool sendAck(ConnectionState &proto) override
Send an acknowledgement, if needed for this carrier.
bool isTextMode() const override
Check if carrier is textual in nature.
virtual bool sendIndex(ConnectionState &proto, SizedWriter &writer)
std::string toString() const override
Get name of carrier.
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
bool prepareSend(ConnectionState &proto) override
Perform any initialization needed before writing on a connection.
A simple abstraction for a block of bytes.
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
The basic state of a connection - route, streams in use, etc.
virtual const Route & getRoute() const =0
Get the route associated with this connection.
virtual void takeStreams(TwoWayStream *streams)=0
Provide streams to be used with the connection.
InputStream & is()
Shorthand for getInputStream()
OutputStream & os()
Shorthand for getOutputStream()
virtual void setRoute(const Route &route)=0
Set the route associated with this connection.
virtual bool isOk() const =0
Check if the stream is ok or in an error state.
virtual void write(char ch)
Write a single byte to the stream.
Information about a connection between two ports.
void setFromName(const std::string &fromName)
Set the source of the route.
Minimal requirements for an efficient Writer.
virtual void write(OutputStream &os)