Android port scanner
<p>I am trying to make a port scanner on Android and I am a little stuck. I want to see if a port is open on the router/default gateway, but nothing seems to be working.  I tried using is reachable, but I feel like that may be the wrong thing.</p>

<pre><code>import java.net.InetAddress;
import java.net.UnknownHostException;

import android.app.Activity; 
import android.content.Context; 
import android.content.Intent; 
import android.content.IntentFilter; 
import android.net.DhcpInfo; 
import android.net.wifi.WifiInfo; 
import android.net.wifi.WifiManager; 
import android.os.Bundle; 
import android.widget.TextView;

public class portscan extends Activity {

String targetHost;
public int startPort = 1; //(for uses in later programming)
public int endPort = 1000;
private Intent scanIntent;
InetAddress targetAddress;
String targetHostName;
WifiManager networkd;
DhcpInfo details;
public String   gateway;
TextView GW;


protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
     try {
    setContentView(R.layout.port);
    GW = (TextView)findViewById(R.id.gateway);
    networkd = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    details = networkd.getDhcpInfo();
    String test = intToIp(details.gateway);

    gateway = "Default Gateway: "+String.valueOf(details.gateway);
    boolean isAvailable = false;

        isAvailable = InetAddress.getByName(test).isReachable(80); //trying to see if port open
        if (isAvailable == true) {
             GW.setText("port 21 is up"); 

        }
    } catch (Exception e) {

    }


}

public String intToIp(int i) { //this converts the DHCP information (default gateway) into a readable network address

       return ( i &amp; 0xFF)+ "." +
                ((i &gt;&gt; 8 ) &amp; 0xFF) + "." +
                ((i &gt;&gt; 16 ) &amp; 0xFF)+ "." +
                ((i &gt;&gt; 24 ) &amp; 0xFF );
    }
</code></pre>
