安卓:progamatically确定有一个TCP连接打开的应用程序列表 [英] Android: progamatically determine list of apps that have a TCP connection open

查看:249
本文介绍了安卓:progamatically确定有一个TCP连接打开的应用程序列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在我的Andr​​oid应用程序连接到哪个IP地址。从本质上讲,我想知道这些应用程序做背景没有我的同意。

I would like know which applications on my android connect to what IP addresses. In essence I would like to know what these apps do in the background without my approval.

我想在我的监视应用程序,这已经让我打开的连接和连接的IP地址netstat的操作系统调用,但没有进程名,PID或UID,让我来映射到一个特定的应用程序的连接。 netstat的-p似乎不提供进程信息。

I tried a netstat OS call in my monitoring app, which already gives me the open connections and the connected IP addresses, but there is no process name, pid or uid that would allow me to map a connection to a particular app. 'netstat -p' seems not to provide the process info.

有什么建议? TIA。

Any suggestions? TIA.

推荐答案

如果你读源$ C ​​$下用'netstat,它实际上是从/ proc /网络/ TCP持有的TCP套接字表的转储读取数据,数据会喜欢下面。

If you read source code for 'netstat', it actually reads data from /proc/net/tcp which holds a dump of the TCP socket table, the data will like below.

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 517 1 cbf19b40 300 0 0 2 -1

你会发现每个连接都有一个UID,由于Android操作系统上运行有这意味着拥有一个唯一的UID的用户帐户的每个应用程序,这将有助于映射每个连接到一个单一的过程。

you will discover each connection has a uid, because Android OS run each application with a user account that means own a unique uid, it will help to map every connection to a single process.

我希望这些信息将有助于。

I hope this information will help.

这篇关于安卓:progamatically确定有一个TCP连接打开的应用程序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆