Mercurial > 510Connectbot
comparison src/com/five_ten_sg/connectbot/service/TerminalMonitor.java @ 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 | d3c5480e8441 |
children | 8bff0bfaec3a |
comparison
equal
deleted
inserted
replaced
409:cb7df3fefe1e | 410:e2a56e383bad |
---|---|
172 bound = service; | 172 bound = service; |
173 Log.i(TAG, "bound to service"); | 173 Log.i(TAG, "bound to service"); |
174 | 174 |
175 try { | 175 try { |
176 InetAddress serverAddr = InetAddress.getByName(LOCALHOST); | 176 InetAddress serverAddr = InetAddress.getByName(LOCALHOST); |
177 monitor_socket = new Socket(serverAddr, MONITORPORT); | 177 int tries = 0; |
178 while (tries < 5) { | |
179 try { | |
180 monitor_socket = new Socket(serverAddr, MONITORPORT); | |
181 } | |
182 catch (IOException e) { | |
183 Log.e(TAG, "exception connecting to monitor socket", e); | |
184 tries = tries + 1; | |
185 Thread.sleep(1000); | |
186 } | |
187 } | |
188 Log.i(TAG, "connected to monitor socket, send init " + init); | |
178 monitor_in = monitor_socket.getInputStream(); | 189 monitor_in = monitor_socket.getInputStream(); |
179 monitor_out = monitor_socket.getOutputStream(); | 190 monitor_out = monitor_socket.getOutputStream(); |
180 Log.i(TAG, "connected to monitor socket, send init " + init); | |
181 monitor_reader = new MyReader(monitor_in); | 191 monitor_reader = new MyReader(monitor_in); |
182 monitor_reader.start(); | 192 monitor_reader.start(); |
183 String x = " " + init; | 193 String x = " " + init; |
184 monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); | 194 monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); |
185 char [] c; | 195 char [] c; |