Commit b9334f6f64781b6274d87b5fb1dccff7ede34937
1 parent
0d0a443b
Exists in
master
and in
3 other branches
Implementing IPC methods.
Showing
3 changed files
with
22 additions
and
16 deletions
Show diff stats
src/include/lib3270++.h
src/lib3270++/ipc/session.cc
| ... | ... | @@ -45,13 +45,6 @@ |
| 45 | 45 | |
| 46 | 46 | namespace TN3270 { |
| 47 | 47 | |
| 48 | - /* | |
| 49 | - void IPC::Session::wait(time_t timeout) { | |
| 50 | - | |
| 51 | - | |
| 52 | - } | |
| 53 | - */ | |
| 54 | - | |
| 55 | 48 | void IPC::Session::connect(const char *url) { |
| 56 | 49 | Request request(*this,"connect"); |
| 57 | 50 | request.push(url).call(); |
| ... | ... | @@ -63,7 +56,24 @@ |
| 63 | 56 | |
| 64 | 57 | // Wait for session state. |
| 65 | 58 | void IPC::Session::waitForReady(time_t timeout) throw() { |
| 66 | - throw std::system_error(EINVAL, std::system_category()); | |
| 59 | + | |
| 60 | + int rc; | |
| 61 | + Request request(*this,"waitforready"); | |
| 62 | + | |
| 63 | + time_t end = time(nullptr) + timeout; | |
| 64 | + | |
| 65 | + while(time(nullptr) < end) { | |
| 66 | + | |
| 67 | + request.call(); | |
| 68 | + | |
| 69 | + request.pop(rc); | |
| 70 | + | |
| 71 | + if(rc == 0) | |
| 72 | + return; | |
| 73 | + | |
| 74 | + } | |
| 75 | + | |
| 76 | + throw std::system_error(ETIMEDOUT, std::system_category()); | |
| 67 | 77 | } |
| 68 | 78 | |
| 69 | 79 | std::string IPC::Session::toString(int baddr, size_t len, char lf) const { | ... | ... |
src/lib3270++/testprogram/testprogram.cc