Note that there are some explanatory texts on larger screens.

plurals
  1. POSocket unable to connect
    text
    copied!<p>Here'e the problem.</p> <p>I have two android phones, both connected to the same wi-fi network. One phone is listening with a ServerSocket and the other attempts to connect with this socket.</p> <p>However, this is not happening. (i.e) The connection does not get established. However, when I create a listening ServerSocket on my PC (also on the same network) and set my phones to connect to the PC, the connection is established.</p> <p>In other words, I am able to create the connection between a phone and PC but not between phone and phone. Does anyone have any idea of what might possibly be causing this problem?</p> <p>Thank you!</p> <p>Below is the code I have used for getting the IPv4 address.</p> <pre><code>WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int ipAddress = wifiInfo.getIpAddress(); int[] address = new int[4]; String ip = ""; for (int i = 0; i &lt; 4; i++) { address[i] = ipAddress % 256; ipAddress /= 256; if (i != 3) ip += (String.valueOf(address[i]) + "."); else ip += String.valueOf(address[i]); } return ip; </code></pre> <p>Edit:</p> <p>I tried logging the exact location and cause and it gave the following error:</p> <pre><code>java.net.SocketException: No route to host at org.apache.harmony.luni.platform.OSNetworkSystem.connect(Native Method) at dalvik.system.BlockGuard$WrappedNetworkSystem.connect(BlockGuard.java:357) at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:207) at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:186) at java.net.Socket.startupSocket(Socket.java:735) at java.net.Socket.&lt;init&gt;(Socket.java:263) at com.test.word.WifiActivity$12.run(WifiActivity.java:460) at java.lang.Thread.run(Thread.java:1027) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload