You only need to bind() to the corresponding network interface's IP address (instead of 0.0.0.0)
However, I don't know how you can get what you want from Java in a reliable way. There is also the case of a VPN which might want to provide its own interface to the network independently of the real connection state. On Fri, Mar 6, 2009 at 12:37 PM, Graeme <[email protected]> wrote: > > 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)<http://developer.android.com/reference/android/net/ConnectivityManager.html#requestRouteToHost%28int,%20int%29> > ] > 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 > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

