Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Listening socket connection" Watch "Listening socket connection" New topic
Author

Listening socket connection

jeet shri
Greenhorn

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
jeet
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
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
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
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.


Ping & DNS - my free Android networking tools app
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Listening socket connection
 
Similar Threads
App to server connection
Stop package installation
new to Socket prgramming
Socket communication outside emulated app
Unit Testing classes that aren't Activity/Service etc