Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.net.ServerSocket.accept () doesn't return on Android
    primarykey
    data
    text
    <p>I am trying to make a way to telnet to an unrooted Droid. I have the <code>INTERNET</code> permission active, I have my device connected on the same network as my <code>Mac OS X</code> box via WiFi, and I am able to ping the port I opened.</p> <p>In initial experiments, I got it to work on a rooted test device, but I had the socket handlers run on the <code>UI Thread</code> rather than a separate thread. Now that I have the network modules on a separate thread, I can't get <code>ServerSocket.accept ()</code> to return. It works on Google's version of android (vanilla), but not on Samsung's or Sony-Ericsson's.</p> <p>When I telnet to it, my attempt would time out, and <code>logcat</code> wouldn't print out any exceptions or errors.</p> <p>Here is a link to a google-code repo of my code: <a href="https://code.google.com/p/android-socket-experiment/" rel="noreferrer">Google-code Repository</a></p> <p>I am running <code>ServerScoket.accept ()</code> on a separate thread, and run the stream processors on another thread as well. Comments on my design (i.e. I should use <code>Handler</code>s or <code>AsyncTasks</code>) are extremely welcome. Right now, in order to Toast the messages received via telnet, I use a Handler with the looper being acquired via a <code>Context</code>.</p> <p>The following is what I get when I run <code>netstat -n</code> on the adb shell on the non-working devices:</p> <pre><code>~$ adb shell netstat -n Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:7777 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:7203 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:47609 127.0.0.1:7777 ESTABLISHED tcp 0 0 127.0.0.1:7777 127.0.0.1:47609 ESTABLISHED tcp 0 0 127.0.0.1:47610 127.0.0.1:7777 ESTABLISHED tcp 0 0 127.0.0.1:7777 127.0.0.1:47610 ESTABLISHED </code></pre> <p>The difference is that in the working devices, they list an IP with my port open in the state, LISTEN.</p> <p><strong>UPDATE</strong>: Having the <code>&lt;uses-permission android:name="INTERNET"/&gt;</code> set in my <code>android_manifest</code>, I tried changing the port number to <code>689</code>. It didn't work; I got a <code>BindException</code>, saying that I may be lacking the INTERNET permission. So, I changed it to <code>1989</code>, and I went back to everything working until <code>accept ()</code>. I assume this is because I ran it on a non-root phone, and I don't have access to ports <code>1024</code> and below.</p> <p><strong>UPDATE</strong>: I ran a really similar program on my Mac, and it worked fine when I tried telnetting to my Mac using the IP address assigned to me. It didn't work when I tried telnetting from another Mac but it didn't seem to connect; the connection would timeout. It did work over an ad-hoc network, though. I still have yet to try it using the droid, but I will update this asap.</p> <p><strong>UPDATE</strong>: I managed to get the app working on 3 separate Droids running Vanilla (Android released by google). It worked on a Nexus, an Apanda A60 (my first device; adb has ceased to detect it for some reason.), and a custom-made, unbranded tablet. Still, because I already offered a pretty big bounty, I plan on seeing this through to the end.</p> <p>As stated earlier, my app works with Vanilla versions of android, but not with modified versions. The three phones that failed to run it were all mid-range models; 2 <code>Samsung GT-i5503</code>s, and a <code>Sony-Ericcson E16i</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload