linconfang
linconfang

Reputation: 25

How to get the process id in android if you know the tcp port the process using

If somebody know the TCP/UDP port, how to get the process id which is using the port in android. if there some common APIs or command lines can do this in all different android os. i don't want to modify the function of searching process id for different android os. Very Thanks!

Upvotes: 0

Views: 1234

Answers (1)

Mattias Backman
Mattias Backman

Reputation: 955

You could install busybox to get commands such as lsof and fuser.

If you don't want to do that, perhaps scripting something to cat /proc/[pid] for each pid and grep for the port you are interested in.

Upvotes: 1

Related Questions