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
@@ -306,7 +306,7 @@ | @@ -306,7 +306,7 @@ | ||
306 | } | 306 | } |
307 | 307 | ||
308 | inline operator bool() const { | 308 | inline operator bool() const { |
309 | - return isConnected() && isReady(); | 309 | + return isReady(); |
310 | } | 310 | } |
311 | 311 | ||
312 | inline operator ProgramMessage() const { | 312 | inline operator ProgramMessage() const { |
src/lib3270++/ipc/session.cc
@@ -45,13 +45,6 @@ | @@ -45,13 +45,6 @@ | ||
45 | 45 | ||
46 | namespace TN3270 { | 46 | namespace TN3270 { |
47 | 47 | ||
48 | - /* | ||
49 | - void IPC::Session::wait(time_t timeout) { | ||
50 | - | ||
51 | - | ||
52 | - } | ||
53 | - */ | ||
54 | - | ||
55 | void IPC::Session::connect(const char *url) { | 48 | void IPC::Session::connect(const char *url) { |
56 | Request request(*this,"connect"); | 49 | Request request(*this,"connect"); |
57 | request.push(url).call(); | 50 | request.push(url).call(); |
@@ -63,7 +56,24 @@ | @@ -63,7 +56,24 @@ | ||
63 | 56 | ||
64 | // Wait for session state. | 57 | // Wait for session state. |
65 | void IPC::Session::waitForReady(time_t timeout) throw() { | 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 | std::string IPC::Session::toString(int baddr, size_t len, char lf) const { | 79 | std::string IPC::Session::toString(int baddr, size_t len, char lf) const { |
src/lib3270++/testprogram/testprogram.cc
@@ -59,13 +59,9 @@ | @@ -59,13 +59,9 @@ | ||
59 | 59 | ||
60 | // host.connect(getenv("LIB3270_DEFAULT_HOST")); | 60 | // host.connect(getenv("LIB3270_DEFAULT_HOST")); |
61 | 61 | ||
62 | - /* | ||
63 | - cout << host << endl; | ||
64 | - | ||
65 | - host << TN3270::ENTER; | ||
66 | - | ||
67 | - cout << host << endl; | ||
68 | - */ | 62 | + if(host) { |
63 | + cout << host << endl; | ||
64 | + } | ||
69 | 65 | ||
70 | return 0; | 66 | return 0; |
71 | } | 67 | } |