- tmp_socket.close();
- } catch (IOException e2) {
- Log.e(TAG, "unable to close() " + mSocketType +
- " socket during connection failure", e2);
+ // This is a blocking call and will only return on a
+ // successful connection or an exception
+ socket.connect();
+
+ input = socket.getInputStream();
+ output = socket.getOutputStream();
+ } catch (IOException e) {
+ // Close the socket
+ try {
+ socket.close();
+ } catch (IOException e2) {
+ if (D) Log.e(TAG, "ConnectThread: Failed to close() socket after failed connection");
+ }
+ input = null;
+ output = null;
+ AltosBluetooth.this.notifyAll();
+ handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED).sendToTarget();
+ if (D) Log.e(TAG, "ConnectThread: Failed to establish connection");
+ return;