- public int getchar() {
- while (buffer_off == buffer_len) {
- try {
- wait_connected();
- buffer_len = input.read(buffer);
- buffer_off = 0;
- } catch (IOException e) {
- if (D) Log.d(TAG, "getchar IOException");
- disconnected();
- return AltosLink.ERROR;
- } catch (java.lang.InterruptedException e) {
- if (D) Log.d(TAG, "getchar Interrupted");
- disconnected();
- return AltosLink.ERROR;
- }
- }
- if (D)
- debug_input(buffer[buffer_off]);
- return buffer[buffer_off++];
- }
-
- public void closing() {
- synchronized(closed_lock) {
- if (D) Log.d(TAG, "Marked closed true");
- closed = true;
- }
- }
-
-
- public void close() {
- if (D) Log.d(TAG, "close(): begin");
-
- closing();
-
- close_socket();
-
- synchronized(this) {
-
- if (input_thread != null) {
- if (D) Log.d(TAG, "close(): stopping input_thread");
- try {
- if (D) Log.d(TAG, "close(): input_thread.interrupt().....");
- input_thread.interrupt();
- if (D) Log.d(TAG, "close(): input_thread.join().....");
- input_thread.join();
- } catch (Exception e) {}
- input_thread = null;
- }
- input = null;
- output = null;
- notifyAll();
- }
- }
-
- //public void flush_output() { super.flush_output(); }
-