#include <AsyncFdWatch.h>
#include <unistd.h> #include <cstdio> #include <iostream> #include <AsyncCppApplication.h> #include <AsyncFdWatch.h> using namespace std; using namespace Async; class MyClass : public SigC::Object { public: MyClass(void) { stdin_watch = new FdWatch(STDIN_FILENO, FdWatch::FD_WATCH_RD); stdin_watch->activity.connect(slot(this, &MyClass::onActivity)); } ~MyClass(void) { delete stdin_watch; } private: FdWatch *stdin_watch; void onActivity(FdWatch *watch) { char buf[1024]; int cnt = read(watch->fd(), buf, sizeof(buf)-1); if (cnt == -1) { perror("read"); Application::app().quit(); return; } buf[cnt] = 0; cout << "Read from STDIN: " << buf << endl; } }; int main(int argc, char **argv) { CppApplication app; MyClass my_class; app.exec(); }
Definition at line 119 of file AsyncFdWatch.h.
|
|
The type of the file descriptor watch.
Definition at line 125 of file AsyncFdWatch.h. |
|
||||||||||||
|
Constructor. Add the given file descriptor to the watch list and watch it for incoming data (FD_WATCH_RD) or write buffer space available (FD_WATCH_WR).
|
|
|
Destructor.
|
|
|
Return the file descriptor being watched.
Definition at line 151 of file AsyncFdWatch.h. |
|
|
Check if the watch is enabled or not.
Definition at line 170 of file AsyncFdWatch.h. |
|
|
Enable or disable the watch.
|
|
|
Return the type of this watch.
Definition at line 157 of file AsyncFdWatch.h. |
|
|
Signal to indicate that the descriptor is active.
Definition at line 176 of file AsyncFdWatch.h. |
1.4.4