Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6720989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:16:38+00:00 2026-05-26T09:16:38+00:00

InetAddress address = InetAddress.getByAddress( new byte[] { (byte) 192, (byte) 168, (byte) 254, (byte)

  • 0

InetAddress address = InetAddress.getByAddress( new byte[] { (byte) 192, (byte) 168, (byte) 254, (byte) 10 ); success = address.isReachable( 3000 );

This returns false even though I am reasonably sure it is a reachable address.

I found that if I changed this to 127, 0, 0, 1 it returned success.

My next attempt was same code, but I used the address I got from a ping of http://www.google.com ( 72.167.164.64 as of this writing ). No success.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:16:38+00:00Added an answer on May 26, 2026 at 9:16 am

    You can create a servlet/webpages or whatever you feel comfortable on the server that return ok or error depending on server status from your android you must call that url and check returned value, also on your try/catch you must watch specific exception for example related with timeout, also check for http status if your http request returned 200 then was ok and you can fetch server status from that url

    Check http://developer.android.com/reference/java/net/HttpURLConnection.html

    boolean isOK = false;
    try {
        URL url = new URL("http://yourserverurl/yourstatusmethod");
        HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();
        urlcon.connect();
        if (urlcon.getResponseCode() == 200) {
                InputStream in = new BufferedInputStream(urlConnection.getInputStream());
                String serverStatus = readStream(in); //assuming that "http://yourserverurl/yourstatusmethod" returns OK or ERROR depending on your server status check         
                isOK = (serverStatus.equalsIgnoreCase("OK"));
        }else{
          isOK = false;
        }
    
        url.disconnect();
    
    } catch (MalformedURLException e1) {
                isOK = false;
                e1.printStackTrace();
    } catch (IOException e) {
                isOK = false;
                e.printStackTrace();
    }
    

    the readStream is a method that convert inputstream to string

    public static String readStream (InputStream in) throws IOException {
        StringBuffer out = new StringBuffer();
        byte[] b = new byte[4096];
        for (int n; (n = in.read(b)) != -1;) {
            out.append(new String(b, 0, n));
        }
        return out.toString();
    }
    

    this is just and idea…. there are a lot of ways to check server availability

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my code: InetAddress address = InetAddress.getByName(www.whyoceans.com); if (!address.isReachable(3000)) { Toast.makeText(this, Unable to ping
I have this function which returns a datatype InetAddress[] public InetAddress [] lookupAllHostAddr(String host)
public void Connect() throws Exception { InetAddress dest; dest = InetAddress.getByName(192.168.1.100); DatagramSocket socket =
I get the Yahoo IP address using InetAddress class in java. The result of
If I look up a IP address from a DNS name as follows: InetAddress
I am using this code to find the MAC address of a machine. This
Does anyone know the code to change an android phone's eth0 IP address (InetAddress)?
I have an int which contains an IP address in network byte order, which
I'm trying to get the MAC address of a linux system with this code:
I'm using InetAddress.getByName(params[0]).isReachable(300000) to determine if my NAS is alive. By measuring the time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.