find all ip address in a network

This code scans my network 255 D-class segments in about 1 sec. I wrote it in VB.net and translated it to C# (apologies if there are any errors). Paste it into a Console project and run. Modify as needed. Note: The code is not production ready and need improvements on especially the instance counting (try … Read more

How to ping a URL in an Android Service?

I think if you just want to ping an url, you can use this code : try { URL url = new URL(“http://” + params[0]); HttpURLConnection urlc = (HttpURLConnection) url.openConnection(); urlc.setRequestProperty(“User-Agent”, “Android Application:”+Z.APP_VERSION); urlc.setRequestProperty(“Connection”, “close”); urlc.setConnectTimeout(1000 * 30); // Timeout is in seconds urlc.connect(); if (urlc.getResponseCode() == 200) { Main.Log(“getResponseCode == 200”); return new Boolean(true); … Read more

How to test an Internet connection with bash?

Without ping #!/bin/bash wget -q –spider http://google.com if [ $? -eq 0 ]; then echo “Online” else echo “Offline” fi -q : Silence mode –spider : don’t get, just check page availability $? : shell return code 0 : shell “All OK” code Without wget #!/bin/bash echo -e “GET http://google.com HTTP/1.0\n\n” | nc google.com 80 … Read more

Check for Active internet connection Android

It does works for me: To verify network availability: private Boolean isNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting(); } To verify internet access: public Boolean isOnline() { try { Process p1 = java.lang.Runtime.getRuntime().exec(“ping -c 1 www.google.com”); int returnVal = p1.waitFor(); boolean reachable = (returnVal==0); return … Read more

TraceRoute and Ping in C#

Given that I had to write a TraceRoute class today I figured I might as well share the source code. using System.Collections.Generic; using System.Net.NetworkInformation; using System.Text; using System.Net; namespace Answer { public class TraceRoute { private const string Data = “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”; public static IEnumerable<IPAddress> GetTraceRoute(string hostNameOrAddress) { return GetTraceRoute(hostNameOrAddress, 1); } private static IEnumerable<IPAddress> GetTraceRoute(string … Read more

How can I ping a server port with PHP?

I think the answer to this question pretty much sums up the problem with your question. If what you want to do is find out whether a given host will accept TCP connections on port 80, you can do this: $host=”193.33.186.70″; $port = 80; $waitTimeoutInSeconds = 1; if($fp = fsockopen($host,$port,$errCode,$errStr,$waitTimeoutInSeconds)){ // It worked } else … Read more