Async 1.5.0
|
A wrapper class for using a PTY. More...
#include <AsyncPty.h>
Public Member Functions | |
Pty (const std::string &slave_link="") | |
Default constructor. | |
~Pty (void) | |
Destructor. | |
bool | open (void) |
Open the PTY. | |
void | close (void) |
Close the PTY if it's open. | |
bool | reopen (void) |
Reopen the PTY. | |
ssize_t | write (const void *buf, size_t count) |
Write data to the PTY. | |
bool | isOpen (void) const |
Check if the PTY is open or not. | |
Public Attributes | |
sigc::signal< void, const void *, size_t > | dataReceived |
Signal that is emitted when data has been received. | |
A wrapper class for using a PTY.
This class wrap up some functionality that is nice to have when using a PTY.
The PTY is opened in raw mode.
If the slave end of the PTY is not open, the master file descriptor will be continuously polled to detect when it is opened. When the slave end of the PTY is open, an FdWatch will be used to check for activity instead of polling.
Data written to the master end will be discarded if the slave end is not open.
Definition at line 124 of file AsyncPty.h.
Async::Pty::Pty | ( | const std::string & | slave_link = "" | ) |
Default constructor.
Async::Pty::~Pty | ( | void | ) |
Destructor.
void Async::Pty::close | ( | void | ) |
Close the PTY if it's open.
Close the PTY if it's open. This function is safe to call even if the PTY is not open or if it's just partly opened.
|
inline |
Check if the PTY is open or not.
Definition at line 181 of file AsyncPty.h.
bool Async::Pty::open | ( | void | ) |
Open the PTY.
Use this function to open the PTY. If the PTY is already open it will be closed first.
bool Async::Pty::reopen | ( | void | ) |
Reopen the PTY.
Try to reopen the PTY. On failure an error message will be printed and the PTY will stay closed.
ssize_t Async::Pty::write | ( | const void * | buf, |
size_t | count | ||
) |
Write data to the PTY.
buf | A buffer containing the data to write |
count | The number of bytes to write |
Use this function to write data to the PTY. If the slave end of the PTY is not open, the written data will just be discarded and count is used as the return value.
sigc::signal<void, const void*, size_t> Async::Pty::dataReceived |
Signal that is emitted when data has been received.
buf | A buffer containing the received data |
count | The number of bytes in the buffer |
Definition at line 188 of file AsyncPty.h.