简体   繁体   中英

Getting which application uses a specific port on android

I have an android native application which hosts a web server inside it. I want to know which application makes requests before they are processed by my application. What I have is the port of the calling application.

How can I find out which application is using this port? I've tried looking for all processes (cat /proc/net/tcp6), but the application with the port I have is not listed (on a rooted device it is). I also tried playing with lots of options of the netstat command, but I don't get any valuable information.

I need to find a way to find the calling application name on a regular device (not rooted).

The uid is a field in /proc/net/tcp6, which at least of the moment is readable from an unprivileged app.

Then you can use PackageManager.getNameForUid()

That said, your goal seems like an odd design.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM