0

I have an android application which is running on Huawei S7,Android 2.2. It is getting inputs from an arduino board.Arduino Board is connected to the tablet by USB cable.Application is using USB Protocol to connect to arduino.

The application is written for Android 4.1.And it is using a backward compatibility pack to make it runnable on 2.2. We had to use a 2.2 device.But now we have a device with Android 4.3. And when we try to run the same app in 4.3 device it gives an error saying 4567 port already in use. 4567 port is the port used by arduino application to connect with the Android Device(Tablet Application).

How can i find the application which is using the 4567 port?

Is there any way i can free up that port?

My 4.3 device is not rooted. Will rooting do any good in this problem?

8
  • You could check whether the netstat binary is available on your device. It's a command line tool, so you'd either need a terminal app or an ADB connection to use it. netstat --tcp --listening -p then should list up all listening ports together with the associated "program" (didn't try this on Android, so I'm not sure whether all options are supported. If you can confirm this, I'll write up an answer).
    – Izzy
    Commented Nov 10, 2013 at 16:19
  • I used terminal emulator app and ran the above command. This is the output i got. drive.google.com/file/d/0B8JZMxx6Km7oZFpqRGJkcUV0cDQ/… Commented Nov 10, 2013 at 16:51
  • Do i need the root access to run this command? Commented Nov 10, 2013 at 16:51
  • Just a second: Your linked screenshot does not use above command. You ran lsof (LiSt Open Files). I wrote netstat --tcp --listening -p. Complete different commands, for different purposes (though partly overlapping). Please ty again :) And no, it should not require root to run netstat (though the -p parameter might ask for it, depending on implementation).
    – Izzy
    Commented Nov 10, 2013 at 17:22
  • Sorry i linked the wrong screen shot. I was trying that command suggested by another stackexchange site user.This is the one i got when running netstat --tcp --listening -p drive.google.com/file/d/0B8JZMxx6Km7od1BzN1BaR1ZGNWc/… Commented Nov 11, 2013 at 0:41

1 Answer 1

0

Without any additional tools, this should be possible via adb shell or a terminal app, using the netstat command: netstat --tcp --listening -p should list up all listening ports along with the app behind it. But it might very well be (as in your case, obviously) that the -p parameter requires root; and without it, the output won't show the app holding the port open.

However, NetStat Plus might offer what you need:

NetStat Plus Connection List
NetStat Plus and Connection List (source: Google Play; click for larger image)

I did not try this app myself, but the screenshots suggest it does exactly what you need: Listing apps with the used ports and status along. No word that it requires root. It further seems to work at least from Gingerbread (2.3.6 is explicitly mentioned) onwards to at least Jelly Bean 4.3 (also explicitly mentioned). An alternative would be Connection List (second screenshot).

4
  • I tried both the apps but any record they generate doesn't show any app using the port 4657. :( Shall i give the screen shots of those too? Commented Nov 11, 2013 at 4:42
  • I don't think that will help. At least the screenshot of Connection list shows it deals with ports in LISTENING mode as well. So if no such is shown with any of the apps (and netstat --tcp --listening | grep ":4657" doesn't yield a result either, then there isn't anything listening there. Maybe some outgoing session was just using the very same port? Have you checked that? If that's the case, it might already be freed again. Try to start your app again. If it fails with the same error, use one of those apps to check for all entries with that port (not only LISTENING).
    – Izzy
    Commented Nov 11, 2013 at 8:10
  • I ran the netstat --tcp --listening | grep ":4657" command and got this result. It has 4567 in it but the complete port number is 45675.I guess it's not the same. drive.google.com/file/d/0B8JZMxx6Km7oMU5NREhldEQwZjA/… drive.google.com/file/d/0B8JZMxx6Km7od3RuMjlJLU1CNk0/… Commented Nov 11, 2013 at 8:48
  • It is as much the same as 4,657 USD and 46,575 USD are the same :) Please, try again with your app. If it shows the same error, check with the apps again as described (and optionally netstat --tcp | grep ":4657" for the general information whether the port is in use, and if so, in which state). Assuming either ESTABLISHED or CLOSE_WAIT, another app could be using it for outgoing connections.
    – Izzy
    Commented Nov 11, 2013 at 9:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .