changeset 410:e2a56e383bad

wait for monitor socket to be created
author Carl Byington <carl@five-ten-sg.com>
date Fri, 24 Oct 2014 17:41:43 -0700
parents cb7df3fefe1e
children 8bff0bfaec3a
files src/com/five_ten_sg/connectbot/service/TerminalMonitor.java src/org/tn5250j/framework/tn5250/KeyStrokenizer.java
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Fri Oct 24 14:35:04 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Fri Oct 24 17:41:43 2014 -0700
@@ -174,10 +174,20 @@
 
             try {
                 InetAddress serverAddr = InetAddress.getByName(LOCALHOST);
-                monitor_socket = new Socket(serverAddr, MONITORPORT);
+                int tries = 0;
+                while (tries < 5) {
+                    try {
+                        monitor_socket = new Socket(serverAddr, MONITORPORT);
+                    }
+                    catch (IOException e) {
+                        Log.e(TAG, "exception connecting to monitor socket", e);
+                        tries = tries + 1;
+                        Thread.sleep(1000);
+                    }
+                }
+                Log.i(TAG, "connected to monitor socket, send init " + init);
                 monitor_in     = monitor_socket.getInputStream();
                 monitor_out    = monitor_socket.getOutputStream();
-                Log.i(TAG, "connected to monitor socket, send init " + init);
                 monitor_reader = new MyReader(monitor_in);
                 monitor_reader.start();
                 String x = "  " + init;
--- a/src/org/tn5250j/framework/tn5250/KeyStrokenizer.java	Fri Oct 24 14:35:04 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/KeyStrokenizer.java	Fri Oct 24 17:41:43 2014 -0700
@@ -42,7 +42,7 @@
     public void setKeyStrokes(String strokes) {
         if (strokes != null) {
             keyStrokes.setLength(0);
-            Log.d(TAG, "set " + keyStrokes);
+            Log.d(TAG, "set " + strokes);
             length = strokes.length();
         }
         else {