Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to broadcast in a wifi network of Android phones
    primarykey
    data
    text
    <p>I have a network of android phones, in which one of the phone acts as server. I try to do a broadcast using the destination IP as <code>'255.255.255.255.'</code>. But it fails to send message. I give the logcat below. The server IP is <code>192.168.43.1</code>. I have also tried with <code>'192.168.43.255'</code>. But it too ended up in vain. For code, I had referred <a href="http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/" rel="nofollow">http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/</a></p> <pre><code>05-30 20:17:40.970: E/ClientActivity(698): java.net.UnknownHostException: /192.168.43.255 05-30 20:17:40.970: E/ClientActivity(698): at java.net.InetAddress.lookupHostByName(InetAddress.java:506) 05-30 20:17:40.970: E/ClientActivity(698): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:294) 05-30 20:17:40.970: E/ClientActivity(698): at java.net.InetAddress.getByName(InetAddress.java:325) 05-30 20:17:40.970: E/ClientActivity(698): at project.android.aec.ConnectActivity$ClientThread.run(ConnectActivity.java:139) 05-30 20:17:40.970: E/ClientActivity(698): at java.lang.Thread.run(Thread.java:1019) </code></pre> <p>The following is the code used to get broadcast IP</p> <pre><code> private InetAddress getBroadcastAddress() throws IOException { mWifi= (WifiManager) getSystemService(Context.WIFI_SERVICE); DhcpInfo dhcp = mWifi.getDhcpInfo(); if (dhcp == null) { Log.d("BCast Address Fetch", "Could not get dhcp info"); return null; } int broadcast = (dhcp.ipAddress &amp; dhcp.netmask) | ~dhcp.netmask; byte[] quads = new byte[4]; for (int k = 0; k &lt; 4; k++) quads[k] = (byte) ((broadcast &gt;&gt; k * 8) &amp; 0xFF); return InetAddress.getByAddress(quads); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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