A stream abstraction for socket communication. More...
#include <yarp/os/impl/SocketTwoWayStream.h>
Public Member Functions | |
SocketTwoWayStream () | |
int | open (const Contact &address) |
int | open (yarp::os::impl::TcpAcceptor &acceptor) |
~SocketTwoWayStream () override | |
InputStream & | getInputStream () override |
Get an InputStream to read from. | |
OutputStream & | getOutputStream () override |
Get an OutputStream to write to. | |
const Contact & | getLocalAddress () const override |
Get the address of the local side of the stream. | |
const Contact & | getRemoteAddress () const override |
Get the address of the remote side of the stream. | |
void | interrupt () override |
Interrupt the stream. | |
void | close () override |
Terminate the stream. | |
yarp::conf::ssize_t | read (Bytes &b) override |
Read a block of data from the stream. | |
yarp::conf::ssize_t | partialRead (Bytes &b) override |
Like read, but solicit partial responses. | |
void | write (const Bytes &b) override |
Write a block of bytes to the stream. | |
void | flush () override |
Make sure all pending write operations are finished. | |
bool | isOk () const override |
Check if the stream is ok or in an error state. | |
void | reset () override |
Reset the stream. | |
void | beginPacket () override |
Mark the beginning of a logical packet. | |
void | endPacket () override |
Mark the end of a logical packet (see beginPacket). | |
bool | setWriteTimeout (double timeout) override |
Set activity timeout. | |
bool | setReadTimeout (double timeout) override |
Set activity timeout. | |
bool | setTypeOfService (int tos) override |
int | getTypeOfService () override |
Public Member Functions inherited from yarp::os::TwoWayStream | |
virtual | ~TwoWayStream () |
Destructor. | |
Public Member Functions inherited from yarp::os::InputStream | |
InputStream () | |
Constructor. | |
virtual | ~InputStream () |
Destructor. | |
virtual void | check () |
Perform maintenance actions, if needed. | |
virtual int | read () |
Read and return a single byte. | |
virtual yarp::conf::ssize_t | read (Bytes &b, size_t offset, yarp::conf::ssize_t len) |
Read a block of data from the stream. | |
std::string | readLine (const char terminal='\n', bool *success=nullptr) |
Read a block of text terminated with a specific marker (or EOF). | |
yarp::conf::ssize_t | readFull (Bytes &b) |
Keep reading until buffer is full. | |
yarp::conf::ssize_t | readDiscard (size_t len) |
Read and discard a fixed number of bytes. | |
virtual bool | setReadEnvelopeCallback (readEnvelopeCallbackType callback, void *data) |
Install a callback that the InputStream will have to call when the envelope is read from a message in carriers that cannot be escaped. | |
Public Member Functions inherited from yarp::os::OutputStream | |
virtual | ~OutputStream () |
Destructor. | |
virtual void | write (char ch) |
Write a single byte to the stream. | |
virtual void | write (const Bytes &b, int offset, int len) |
Write a block of bytes to the stream. | |
virtual void | writeLine (const char *data, int len) |
Write some text followed by a line feed. | |
Additional Inherited Members | |
Public Types inherited from yarp::os::InputStream | |
typedef void(* | readEnvelopeCallbackType) (void *, const yarp::os::Bytes &envelope) |
Callback type for setting the envelope from a message in carriers that cannot be escaped. | |
A stream abstraction for socket communication.
It supports TCP.
Definition at line 36 of file SocketTwoWayStream.h.
|
inline |
Definition at line 42 of file SocketTwoWayStream.h.
|
inlineoverride |
Definition at line 53 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Mark the beginning of a logical packet.
This is a unit that should be treated in an atomic fashion by YARP. If any part is corrupted, the whole should be dropped.
Implements yarp::os::TwoWayStream.
Definition at line 185 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Terminate the stream.
Implements yarp::os::TwoWayStream.
Definition at line 92 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Mark the end of a logical packet (see beginPacket).
Implements yarp::os::TwoWayStream.
Definition at line 194 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Make sure all pending write operations are finished.
Reimplemented from yarp::os::OutputStream.
Definition at line 159 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Get an InputStream to read from.
Implements yarp::os::TwoWayStream.
Definition at line 58 of file SocketTwoWayStream.h.
Get the address of the local side of the stream.
Implements yarp::os::TwoWayStream.
Definition at line 68 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Get an OutputStream to write to.
Implements yarp::os::TwoWayStream.
Definition at line 63 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Get the address of the remote side of the stream.
Implements yarp::os::TwoWayStream.
Definition at line 73 of file SocketTwoWayStream.h.
|
overridevirtual |
Reimplemented from yarp::os::OutputStream.
Definition at line 151 of file SocketTwoWayStream.cpp.
|
inlineoverridevirtual |
Interrupt the stream.
If the stream is currently in a blocked state, it must be unblocked.
Reimplemented from yarp::os::InputStream.
Definition at line 78 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Check if the stream is ok or in an error state.
Implements yarp::os::TwoWayStream.
Definition at line 176 of file SocketTwoWayStream.h.
Definition at line 32 of file SocketTwoWayStream.cpp.
int SocketTwoWayStream::open | ( | yarp::os::impl::TcpAcceptor & | acceptor | ) |
Definition at line 78 of file SocketTwoWayStream.cpp.
|
inlineoverridevirtual |
Like read, but solicit partial responses.
Reimplemented from yarp::os::InputStream.
Definition at line 120 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Read a block of data from the stream.
Should block and wait for data.
b[out] | the block of data to read to |
Implements yarp::os::InputStream.
Definition at line 99 of file SocketTwoWayStream.h.
|
inlineoverridevirtual |
Reset the stream.
Implements yarp::os::TwoWayStream.
Definition at line 181 of file SocketTwoWayStream.h.
Set activity timeout.
Support for this is optional. 0 = wait forever.
Reimplemented from yarp::os::InputStream.
Definition at line 214 of file SocketTwoWayStream.h.
Reimplemented from yarp::os::OutputStream.
Definition at line 145 of file SocketTwoWayStream.cpp.
Set activity timeout.
Support for this is optional. 0 = wait forever.
Reimplemented from yarp::os::OutputStream.
Definition at line 203 of file SocketTwoWayStream.h.
Write a block of bytes to the stream.
b | the bytes to write |
Implements yarp::os::OutputStream.
Definition at line 142 of file SocketTwoWayStream.h.