#include <lib.h>
When an attempt to read has been issued to this class, no other code should read from the file descriptor, as it will mess up the buffers.
Public Member Functions | |
| Readfd (int fd) | |
| int | read_line (std::string &str) |
Tries to read a line without blocking and writes the result into str. | |
| int | read_bytes (std::string &str, size_t count) |
Tries to read count bytes into str without blocking. | |
| int | event (int timeout=-1) |
Blocks until the file descriptor becomes ready for reading or timeout (milliseconds) elapses. | |
| bool | eof () |
| Returns true if an EOF or error condition has occured. | |
| size_t | buflimit () |
| Returns the max allowed size of the internal memory buffer. | |
| size_t | buflimit (size_t set) |
| Sets the max allowed size of the internal memory buffer. | |
Protected Attributes | |
| int | _fd |
| size_t | _len |
| size_t | _pos |
| size_t | _buflimit |
| char * | _buf |
| pollfd | _pollfd |
Static Protected Attributes | |
| const size_t | _readsize = 1024 |
|
|
|
|
|
Sets the max allowed size of the internal memory buffer. If the buffer grows beyond this, it will be treated as a read error, protecting against DOS attacks. |
|
|
Returns true if an EOF or error condition has occured. If this happens, the Readfd object is no use anymore and should be destroyed. |
|
|
Blocks until the file descriptor becomes ready for reading or
|
|
||||||||||||
|
Tries to read
Has three possible return values: 1 if something could be read (not necessarily all |
|
|
Tries to read a line without blocking and writes the result into Has three possible return values: 1 if it succeeds, 0 if reading would block and -1 if there was an error on the file descriptor. |
1.3.3