Can I force Android to open a network connection on a specified network interface/network type ?

by Graeme » Fri, 06 Mar 2009 19:37:59 GMT


Sponsored Links
 Hi

I have been looking at the ConnectivityManager class documented at
 http://developer.android.com/reference/android/net/ConnectivityManager.html 
.

I would like to know if an Android application can open a network
connection (socket) on a specified network interface [on a device
supporting multiple network interface types WiFi, Cellular, WiMax
etc] ? I am looking for the capability for an application to open a
socket on a given type of network for example
over WiFi network or over 3G Cellular Data network.

If this is possible in Android, how would I code this requirement
within the API Framework ?
The ConnectivityManager enables an application to learn about
available network connections and
currently categorises them as either TYPE_WIFI or TYPE_MOBILE.

There is a member function in the ConnectivityManager class  called
requestRouteToHost(int,int) [see
 http://developer.android.com/reference/android/net/ConnectivityManager.html #requestRouteToHost(int,%20int)]
which "Ensure that a network route exists to deliver traffic to the
specified host via the specified network interface. An attempt to add
a route that already exists is ignored, but treated as successful."
Sounds like this would install an IP routing table entry to reach a
given host via a specified network interface type (WiFi or Mobile).
After calling this would it be sufficient for an application to open a
socket and connect to the desired destination address ?

Or perhaps the application needs to bind() a socket to a local address
of a network interface of the desired type (WiFi or Mobile)

Or by setting a socket-level socket option of SO_DONTROUTE ?

Any help would be appreciated
Thanks
Graeme
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Froyo build error WifiConfiguration

Hi All,
I posted this question in android-building and I got suggestion that I
should be posting it porting group.

$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.2.1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=MASTER
============================================
============================================
find: wifi: No such file or directory
find: vpn: No such file or directory
find: wifi: No such file or directory
find: vpn: No such file or directory
Aidl: framework <= frameworks/base/core/java/android/os/
INetworkManagementService.aidl
frameworks/base/core/java/android/os/INetworkManagementService.aidl:
22: couldn't find import for class android.net.wifi.WifiConfiguration
make: *** [out/target/common/obj/JAVA_LIBRARIES/
framework_intermediates/src/core/java/android/os/
INetworkManagementService.java] Error 1


Has anyone see it before? I have no luck with google search. My device
has no wifi so is there a way to disable wifi from the build?
thanks in advance.
lb

-- 

2. Safety and Bluetooth

Hi everyone,

I am developing a mobile ticketing application for public transport
and I need to implement a secure data exchange between two mobile
devices via bluetooth (such as TLS), user to ticket controller, to
allow the validation of the ticket. How can i do this?

thanks
Marco

-- 
.

3. List adapter listview

4. Solution for P2P messaging on Wifi LAN

5. Gathering

6. part time data entry jobs.

7. All latest fresher