'finding pid for a port without busybox in Android
We are using an special android without possibility to installs app. When I am running netstat I can see that port 1975 is in Listen State. I want to know which process is using this port but without using busybox. Is there a way to do this?
Another question is that why It is not possible to apply netstat or lsof switches while using adb shell? It seems that adb shell is ignoring switches and printing same result. The netstat output is always like 
Solution 1:[1]
lsof -i is not available for Android.
1.cat /proc/net/tcp
you will get a list of all ports with their processes.
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 0100007F:13AD 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 3336108 1 0000000000000000 100 0 0 10 0
1: 0100007F:1f90 00000000:0000 0A 00000000:00000000 00:00000000 00000000 10252 0 3579923 1 0000000000000000 100 0 0 10 0
this result shows the '8080' port is using by uid 10252. ( 8080 = 1f90 hex value)
2.cat /data/system/packages.list | grep 10252
will show your the package name of the app.
merlin:/ # cat /data/system/packages.list | grep 10252
com.la391.f6a85e 10252 0 /data/user/0/com.la391.f6a85e default:targetSdkVersion=29 3002,3003 0 1
Solution 2:[2]
lsof might be useful, try this
lsof -i :port
OR netstat
netstat -atnp | grep port
note: p - shows the pid of linked port
OR ss tool
ss -tanp | grep port
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |
