Back to project page PortAuthority.
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.
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); } } } }