The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the socket. This means, it has to have some knowledge about the package structure to peek at the field defining the package length. This is why it is templated with the package header type.
More...
#include <stream.h>
|
bool | closed () |
| Returns whether the underlying socket is currently closed. More...
|
|
bool | connect () |
| Connects to the configured socket. More...
|
|
void | disconnect () |
| Disconnects from the configured socket. More...
|
|
bool | read (uint8_t *buf, const size_t buf_len, size_t &read) |
| Reads a full UR package out of a socket. For this, it looks into the package and reads the byte length from the socket directly. It returns as soon as all bytes for the package are read from the socket. More...
|
|
| URStream (const std::string &host, int port) |
| Creates a new URStream object. Note, that this does not immediately open the socket, that has to be done separately by calling the connect() function. More...
|
|
bool | write (const uint8_t *buf, const size_t buf_len, size_t &written) |
| Writes directly to the underlying socket (with a mutex guard) More...
|
|
void | close () |
| Closes the connection to the socket. More...
|
|
std::string | getIP () const |
| Determines the local IP address of the currently configured socket. More...
|
|
int | getSocketFD () |
| Getter for the file descriptor of the socket. More...
|
|
SocketState | getState () |
| Getter for the state of the socket. More...
|
|
bool | read (char *character) |
| Reads one byte from the socket. More...
|
|
bool | read (uint8_t *buf, const size_t buf_len, size_t &read) |
| Reads data from the socket. More...
|
|
void | setReceiveTimeout (const timeval &timeout) |
| Setup Receive timeout used for this socket. More...
|
|
| TCPSocket () |
| Creates a TCPSocket object. More...
|
|
bool | write (const uint8_t *buf, const size_t buf_len, size_t &written) |
| Writes to the socket. More...
|
|
virtual | ~TCPSocket () |
|
|
virtual bool | open (int socket_fd, struct sockaddr *address, size_t address_len) |
|
virtual void | setOptions (int socket_fd) |
|
bool | setup (std::string &host, int port) |
|
template<typename T>
class urcl::comm::URStream< T >
The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the socket. This means, it has to have some knowledge about the package structure to peek at the field defining the package length. This is why it is templated with the package header type.
Definition at line 42 of file stream.h.
Creates a new URStream object. Note, that this does not immediately open the socket, that has to be done separately by calling the connect() function.
- Parameters
-
host | IP address of the remote host |
port | Port on which the socket shall be connected |
Definition at line 52 of file stream.h.
Returns whether the underlying socket is currently closed.
Definition at line 78 of file stream.h.
Connects to the configured socket.
- Returns
- True on success, false if connection could not be established
Definition at line 61 of file stream.h.
Disconnects from the configured socket.
Definition at line 69 of file stream.h.
template<typename T>
virtual bool urcl::comm::URStream< T >::open |
( |
int |
socket_fd, |
|
|
struct sockaddr * |
address, |
|
|
size_t |
address_len |
|
) |
| |
|
inlineprotectedvirtual |
Reads a full UR package out of a socket. For this, it looks into the package and reads the byte length from the socket directly. It returns as soon as all bytes for the package are read from the socket.
- Parameters
-
[out] | buf | The byte buffer where the content shall be stored |
[in] | buf_len | Number of bytes allocated for the buffer |
[out] | read | Number of bytes actually read from the socket |
- Returns
- True on success, false on error, e.g. the buffer is smaller than the package size
Definition at line 127 of file stream.h.
template<typename T >
bool urcl::comm::URStream< T >::write |
( |
const uint8_t * |
buf, |
|
|
const size_t |
buf_len, |
|
|
size_t & |
written |
|
) |
| |
Writes directly to the underlying socket (with a mutex guard)
- Parameters
-
[in] | buf | Byte stream that should be sent |
[in] | buf_len | Number of bytes in buffer |
[out] | written | Number of bytes actually written to the socket |
- Returns
- False if sending went wrong
Definition at line 120 of file stream.h.
The documentation for this class was generated from the following file:
ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Sun May 9 2021 02:16:26