File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes Listening socket connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Listening socket connection" Watch "Listening socket connection" New topic

Listening socket connection

jeet shri

Joined: May 13, 2011
Posts: 1
Hi all

I am developing an android application in which i need to implement a background service which will will listen the socket connection made by any of the app of device.
in other words i want to capture the event when any app try to make server connection.
and then i want to fetch the destination ip address or domain name.

can any one tell me is this possible in android.
either by SDK or NDk

With thanks
Hauke Ingmar Schmidt

Joined: Nov 18, 2008
Posts: 436
I hope it is not possible on API level! What a security risc this would be - sandboxing, something quite important in Android, would be rendered useless. It may be possible at sytem level (e.g. TCP/IP stack, network driver).
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
I wouldn't call it a security risk - with an explicit permission that the app would need to have (and which the user would need to agree to), it wouldn't be much different from installing apps that can listen to phone calls and SMS, or that have access to calendar and contact details, IMO.

Having said that, I'm nonetheless unaware of such a capability.
Hauke Ingmar Schmidt

Joined: Nov 18, 2008
Posts: 436
Maybe I was a little harsh. And there are legit use cases.

But it would mean that an app can directly control what another one does, by directly interfering with the output/input. This is something the Android designers tried to avoid with the concept of sandboxing, intents and loose coupling. The data objects you name (SMS, phone calls, contacts) are public objects in Android by design. When an app creates files it can create public or private files. I would expect a socket connection to be private, at least by default.

Even for taking screenshots (possibly reading the output of another app) you need an app with root privileges.
I agree. Here's the link:
subject: Listening socket connection
It's not a secret anymore!