36 this->sender = sender;
51 this->receiver = receiver;
54 receiverMutex.unlock();
60 if (sender == carrier) {
69 this->sender = sender;
130 if (owner !=
nullptr) {
145 peerMutex(), sent(0), received(0)
176 if (peer !=
nullptr) {
177 peer->accept(
nullptr);
218 if (header.
length() == 8) {
219 std::string target = getSpecifierName();
220 for (
int i = 0;
i < 8;
i++) {
221 if (!(target[
i] == header.
get()[
i])) {
232 if (header.
length() == 8) {
233 std::string target = getSpecifierName();
234 for (
int i = 0;
i < 8;
i++) {
235 header.
get()[
i] = target[
i];
247 portName = proto.
getRoute().getFromName();
249 manager.setSender(
this);
251 defaultSendHeader(proto);
254 peer = manager.getReceiver();
256 "sender %p sees receiver %p",
266 portName = proto.
getRoute().getToName();
269 peer = manager.getSender(
this);
271 "receiver %p (%s) sees sender %p (%s)",
275 peer->portName.c_str());
287 if (stream !=
nullptr) {
288 stream->attach(
this, sender);
298 if (ref !=
nullptr) {
300 if (peer !=
nullptr) {
316 return becomeLocal(proto,
false);
323 return becomeLocal(proto,
true);
334 if (ref !=
nullptr) {
350 if (ref !=
nullptr && !doomed) {
A mini-server for performing network communication in the background.
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 void setReference(yarp::os::Portable *ref)=0
Give a direct pointer to an object being sent on the connection.
virtual const Route & getRoute() const =0
Get the route associated with this connection.
InputStream & is()
Shorthand for getInputStream()
virtual void takeStreams(TwoWayStream *streams)=0
Provide streams to be used with the connection.
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.
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.