title: Is it possible to use both the Wi-Fi (wlan) and Cellular Data 4G/LTE (rmnet) interface simultaneously on Android?
body: <p>I am working in an application that requires an Android device to connect to a Wi-Fi network. This Wi-Fi network does not have internet access - it is a Wi-Fi network created by a end-device and used only to communicate with it using TCP sockets. I would like to be able to access the cellular data internet connection on the Android device WHILE communicating with this device over Wi-Fi and I wanted to know if this is possible.</p>
  
  <hr>
  
  <p>Here is what I know so far:</p>
  
  <ol>
  <li>It is possible to get list of all interfaces available on the device and their corresponding IP addresses via the Android <a href="https://developer.android.com/reference/java/net/NetworkInterface.html" rel="nofollow noreferrer">NetworkInterface</a> API.</li>
  <li>There is an option in the Developer Settings in Android to keep cellular data interface up even when Wi-Fi is connected.</li>
  <li>It is possible to provide the <a href="https://developer.android.com/reference/java/net/Socket.html#Socket(java.net.InetAddress,%20int,%20java.net.InetAddress,%20int)" rel="nofollow noreferrer">local address for the Socket to bind to when creating a Socket()</a></li>
  </ol>
  
  <hr>
  
  <p>With these in mind:</p>
  
  <p>When I am connected to the Wi-Fi network with the SIM card in the device and LTE enabled I am able to get <strong>wlan0 interface</strong> with a "local" IP address in the format 192.168.x.x and <strong>rmnet0 interface</strong> with a non-local IP address.</p>
  
  <p>However, depending on the device, I am only ever able to access ONE of them at a time. </p>
  
  <hr>
  
  <p>For example, on a Pixel 2 XL running Oreo 8.1, LTE Enabled, Cellular Data Always On enabled: </p>
  
  <p>I am unable to communicate over Wi-Fi AT ALL. Any Sockets created with the Wi-Fi local address time out. </p>
  
  <hr>
  
  <p>On a Galaxy Tab S2 SM-T818W running Nougat 7.1, LTE Enabled, Cellular Data Always On enabled:</p>
  
  <p>I am able to communicate over Wi-Fi but not able access the cellular data interface. </p>
  
  <hr>
  
  <p>The only way I am able to access the wlan0 interface on the Pixel 2 XL is by calling <a href="https://developer.android.com/reference/android/net/ConnectivityManager.html#requestNetwork(android.net.NetworkRequest,%20android.net.ConnectivityManager.NetworkCallback)" rel="nofollow noreferrer">requestNetwork</a> from Android's <a href="https://developer.android.com/reference/android/net/ConnectivityManager.html" rel="nofollow noreferrer">ConnectivityManager API</a> and requesting Network with TRANSPORT_WIFI capabilities but this defeats the purpose since now all communication and sockets will be bound only to the Wi-Fi network. </p>
  
  <p>I know that when USB tethering is enabled, it is possible to access devices on the Virtual USB "Ethernet Network" interface which shows up as eth0 with either the wlan0 interface or even the rmnet0 interface by specifying local addresses on the Socket connection calls. It just appears to be a problem with Wi-Fi and cellular data.</p>
  
  <hr>
  
  <p>I wanted to know if this is an inherent and intended Android limitation or is there a way to access both interfaces at the same time that I am missing.</p>
  
  <p>Appreciate your help. Please let me know if it would be better for me to provide specific code snippets, I wasn't sure since it would make this post quite long.</p>
  
  <p>Best,</p>