- wait_connected();
- if (D) Log.i(TAG, "getchar(): proceeding");
- return input.read();
- } catch (IOException e) {
- connection_failed();
- } catch (java.lang.InterruptedException e) {
- connection_failed();
- }
- return AltosLink.ERROR;
- }
-
- public void close() {
- if (D) Log.i(TAG, "close(): begin");
- synchronized(this) {
- if (D) Log.i(TAG, "close(): synched");
-
- if (connect_thread != null) {
- if (D) Log.i(TAG, "close(): stopping connect_thread");
- connect_thread.cancel();
- connect_thread = null;
- }
- if (D) Log.i(TAG, "close(): Closing socket");
- try {
- socket.close();
- } catch (IOException e) {
- if (D) Log.e(TAG, "close(): unable to close() socket");
- }
- if (input_thread != null) {
- if (D) Log.i(TAG, "close(): stopping input_thread");
- try {
- if (D) Log.i(TAG, "close(): input_thread.interrupt().....");
- input_thread.interrupt();
- if (D) Log.i(TAG, "close(): input_thread.join().....");
- input_thread.join();
- } catch (Exception e) {}
- input_thread = null;
- }
- input = null;
- output = null;
- notifyAll();
+ return input.read(buffer, 0, len);
+ } catch (IOException ie) {
+ return -1;