Android Open Source - PortAuthority Scan Hosts Runnable






From Project

Back to project page PortAuthority.

License

The source code is released under:

GNU General Public License

If you think the Android project PortAuthority listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.aaronjwood.portauthority.runnable;
/*from  ww  w  . j a  v a2s .  c  om*/
import android.util.Log;

import com.aaronjwood.portauthority.response.MainAsyncResponse;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class ScanHostsRunnable implements Runnable {

    private static final String TAG = "ScanHostsRunnable";

    private String[] ipParts;
    private int start;
    private int stop;
    private MainAsyncResponse delegate;

    public ScanHostsRunnable(String[] ipParts, int start, int stop, MainAsyncResponse delegate) {
        this.ipParts = ipParts;
        this.start = start;
        this.stop = stop;
        this.delegate = delegate;
    }

    @Override
    public void run() {
        for(int i = this.start; i <= this.stop; i++) {
            String newIp = this.ipParts[0] + "." + this.ipParts[1] + "." + this.ipParts[2] + "." + i;
            try {
                InetAddress address = InetAddress.getByName(newIp);
                address.isReachable(100);
            }
            catch(UnknownHostException e) {
                Log.e(this.TAG, e.getMessage());
            }
            catch(IOException e) {
                Log.e(this.TAG, e.getMessage());
            }
            finally {
                this.delegate.processFinish(1);
            }
        }
    }
}




Java Source Code List

com.aaronjwood.portauthority.activity.HostActivity.java
com.aaronjwood.portauthority.activity.MainActivity.java
com.aaronjwood.portauthority.async.GetExternalIpAsyncTask.java
com.aaronjwood.portauthority.async.GetHostnameAsyncTask.java
com.aaronjwood.portauthority.async.ScanHostsAsyncTask.java
com.aaronjwood.portauthority.async.ScanPortsAsyncTask.java
com.aaronjwood.portauthority.network.Discovery.java
com.aaronjwood.portauthority.network.Host.java
com.aaronjwood.portauthority.network.Wireless.java
com.aaronjwood.portauthority.response.HostAsyncResponse.java
com.aaronjwood.portauthority.response.MainAsyncResponse.java
com.aaronjwood.portauthority.runnable.ScanHostsRunnable.java
com.aaronjwood.portauthority.runnable.ScanPortsRunnable.java