39 this->sender = sender;
54 this->receiver = receiver;
57 receiverMutex.unlock();
63 if (sender == carrier) {
72 this->sender = sender;
133 if (owner !=
nullptr) {
148 peerMutex(), sent(0), received(0)
179 if (peer !=
nullptr) {
180 peer->accept(
nullptr);
221 if (header.
length() == 8) {
222 std::string target = getSpecifierName();
223 for (
int i = 0; i < 8; i++) {
224 if (!(target[i] == header.
get()[i])) {
235 if (header.
length() == 8) {
236 std::string target = getSpecifierName();
237 for (
int i = 0; i < 8; i++) {
238 header.
get()[i] = target[i];
252 manager.setSender(
this);
254 defaultSendHeader(proto);
257 peer = manager.getReceiver();
259 "sender %p sees receiver %p",
272 peer = manager.getSender(
this);
274 "receiver %p (%s) sees sender %p (%s)",
278 peer->portName.c_str());
290 if (stream !=
nullptr) {
291 stream->attach(
this, sender);
301 if (ref !=
nullptr) {
303 if (peer !=
nullptr) {
306 yCError(LOCALCARRIER,
"local send failed - write without peer");
310 yCError(LOCALCARRIER,
"local send failed - no object");
319 return becomeLocal(proto,
false);
326 return becomeLocal(proto,
true);
332 yCDebug(LOCALCARRIER,
"local recv: wait send");
334 yCDebug(LOCALCARRIER,
"local recv: got send");
337 if (ref !=
nullptr) {
338 yCDebug(LOCALCARRIER,
"local recv: received");
340 yCDebug(LOCALCARRIER,
"local recv: shutdown");
351 yCDebug(LOCALCARRIER,
"local send: send ref");
353 if (ref !=
nullptr && !doomed) {
354 yCDebug(LOCALCARRIER,
"local send: wait receipt");
356 yCDebug(LOCALCARRIER,
"local send: received");
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 setReference(yarp::os::Portable *ref)=0
Give a direct pointer to an object being sent on the connection.
virtual void takeStreams(TwoWayStream *streams)=0
Provide streams to be used with the connection.
InputStream & is()
Shorthand for getInputStream()
virtual void setRoute(const Route &route)=0
Set the route associated with this connection.
Simple specification of the minimum functions needed from output streams.
This is a base class for objects that can be both read from and be written to the YARP network.
Information about a connection between two ports.
const std::string & getToName() const
Get the destination of the route.
const std::string & getFromName() const
Get the source of the route.
void setFromName(const std::string &fromName)
Set the source of the route.
Minimal requirements for an efficient Writer.
virtual Portable * getReference()=0
Coordinate ports communicating locally within a process.
void setSender(LocalCarrier *sender)
LocalCarrier * getReceiver()
void revoke(LocalCarrier *carrier)
LocalCarrier * getSender(LocalCarrier *receiver)
A stream for communicating locally within a process.
bool isOk() const override
Check if the stream is ok or in an error state.
void interrupt() override
Interrupt the stream.
InputStream & getInputStream() override
Get an InputStream to read from.
const Contact & getLocalAddress() const override
Get the address of the local side of the stream.
OutputStream & getOutputStream() override
Get an OutputStream to write to.
void close() override
Terminate the stream.
void beginPacket() override
Mark the beginning of a logical packet.
void write(const yarp::os::Bytes &b) override
Write a block of bytes to the stream.
void attach(LocalCarrier *owner, bool sender)
void endPacket() override
Mark the end of a logical packet (see beginPacket).
bool setTypeOfService(int tos) override
const Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
void reset() override
Reset the stream.
A carrier for communicating locally within a process.
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
static LocalCarrierManager manager
bool write(ConnectionState &proto, SizedWriter &writer) override
Write a message.
void accept(yarp::os::Portable *ref)
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
bool expectExtraHeader(ConnectionState &proto) override
Receive any carrier-specific header.
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
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 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.
virtual bool becomeLocal(ConnectionState &proto, bool sender)
virtual std::string getSpecifierName() const
bool expectIndex(ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
void getHeader(Bytes &header) const override
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
bool isLocal() const override
Check if carrier operates within a single process.
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
bool isConnectionless() const override
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
#define yCError(component,...)
#define yCAssert(component, x)
#define yCDebug(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
An interface to the operating system, including Port based communication.