Problem using org.apache.commons.net with Android

Put your problem here if it does not fit any of the other categories.

Problem using org.apache.commons.net with Android

Postby rackham » Mon Jan 04, 2010 6:06 pm

Hello all.

I have been successfully using the org.apache.commons.net.telnet
package with my android app, but i have run into a problem.

I have an instance of TelnetClient, which works fine, but when i call
TelnetClient.disconnect it just hangs and nothing happens at all.

A small test case...hangs when disconnect is called. Works fine on my
home machine but not on the emulator. Please help as Im not sure whats
happening here...

Thanks, (code below)

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private TelnetClient telnet = new TelnetClient();
  2.  
  3. private InputStream in;
  4.  
  5. private PrintStream out;
  6.  
  7.  
  8.  
  9. public class Test{
  10.  
  11.  
  12.  
  13.    public Test(){
  14.  
  15.  
  16.  
  17.        try {
  18.  
  19.                        telnet.connect( ipAddress, port );
  20.  
  21.  
  22.  
  23.                        // Get input and output stream references
  24.  
  25.                        in = telnet.getInputStream();
  26.  
  27.                        out = new PrintStream( telnet.getOutputStream() );
  28.  
  29.  
  30.  
  31.                        Log.d(TAG, "test disconnect");
  32.  
  33.  
  34.  
  35.                        telnet.disconnect(); //HERE
  36.  
  37.  
  38.  
  39.                        Log.d(TAG, "test disconnected");
  40.  
  41.  
  42.  
  43.                } catch (SocketException e) {
  44.  
  45.                        // TODO Auto-generated catch block
  46.  
  47.                        e.printStackTrace();
  48.  
  49.                } catch (IOException e) {
  50.  
  51.                        // TODO Auto-generated catch block
  52.  
  53.                        e.printStackTrace();
  54.  
  55.                }
  56.  
  57.  
  58.  
  59. }
  60.  
  61. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
rackham
Junior Developer
Junior Developer
 
Posts: 15
Joined: Tue Oct 06, 2009 10:47 am

Top

Postby rackham » Mon Jan 04, 2010 9:59 pm

Please can anyone help, why is this small bit of code not functioning correctly, i can only assume its some OS or Davlik specific behaviour, any ideas?
rackham
Junior Developer
Junior Developer
 
Posts: 15
Joined: Tue Oct 06, 2009 10:47 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 15 guests