Commit b9334f6f64781b6274d87b5fb1dccff7ede34937

Authored by Perry Werneck
1 parent 0d0a443b

Implementing IPC methods.

src/include/lib3270++.h
... ... @@ -306,7 +306,7 @@
306 306 }
307 307  
308 308 inline operator bool() const {
309   - return isConnected() && isReady();
  309 + return isReady();
310 310 }
311 311  
312 312 inline operator ProgramMessage() const {
... ...
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
... ... @@ -59,13 +59,9 @@
59 59  
60 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 66 return 0;
71 67 }
... ...