|
CARMA C++
|
Read a series of bytes with a timeout and return a raw byte string with the contents of the read. More...
#include <carma/ui/rtd/common/ReaderWithTimeout.h>
Public Types | |
| enum | { SUCCESS, BROKEN_CNX, TIMEOUT, IOCTL_ERROR, POLL_ERROR, READ_ERROR } |
| Error codes. More... | |
Public Member Functions | |
| bool | getBytes (std::string &bytes, struct::timeval tv) |
| Read input from file and put into input string. More... | |
| bool | getBytes (std::string &bytes) |
| int | getErrorCode () const |
| Get error code of last IO. More... | |
| ReaderWithTimeout () | |
| Constructor. More... | |
| ReaderWithTimeout (const struct::timeval tv) | |
| Constructor. More... | |
| ReaderWithTimeout (const int fd, const struct::timeval tv) | |
| Constructor. More... | |
Read a series of bytes with a timeout and return a raw byte string with the contents of the read.
All byte strings begin with a 4-byte integer (in network byte order) which contains the number of bytes in the packet. The data follows immediately.
Works fine with sockets.
Definition at line 33 of file ReaderWithTimeout.h.
| anonymous enum |
Error codes.
Definition at line 59 of file ReaderWithTimeout.h.
| carma::ui::rtd::ReaderWithTimeout::ReaderWithTimeout | ( | ) |
Constructor.
| carma::ui::rtd::ReaderWithTimeout::ReaderWithTimeout | ( | const struct::timeval | tv | ) |
Constructor.
| carma::ui::rtd::ReaderWithTimeout::ReaderWithTimeout | ( | const int | fd, |
| const struct::timeval | tv | ||
| ) |
Constructor.
| bool carma::ui::rtd::ReaderWithTimeout::getBytes | ( | std::string & | bytes, |
| struct::timeval | tv | ||
| ) |
Read input from file and put into input string.
If an error is encountered, an error message is put in the string.
| input | string in which to place input from stdin |
| timeoutSeconds | timeout for receiving the input (seconds) |
| int carma::ui::rtd::ReaderWithTimeout::getErrorCode | ( | ) | const |
Get error code of last IO.