Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38369

Re: How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress present in the server or not???

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <nospam@rabbitbrush.frazmtn.com>
Newsgroups comp.lang.java.programmer
Subject Re: How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress present in the server or not???
Date Wed, 13 Jun 2018 11:01:26 -0500
Organization A noiseless patient Spider
Lines 42
Message-ID <pfrf4m$3i9$1@dont-email.me> (permalink)
References <f1d70a92-e43f-4065-8c03-1bcb8782d737@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 13 Jun 2018 16:01:27 -0000 (UTC)
Injection-Info reader02.eternal-september.org; posting-host="0a9b75572db03bf22ee48251f63a437e"; logging-data="3657"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kntgM3XNBiqgAQfK9K71H"
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0
Cancel-Lock sha1:RjUcdxMjfPZiVzU0B3BdlqJc0SI=
In-Reply-To <f1d70a92-e43f-4065-8c03-1bcb8782d737@googlegroups.com>
Content-Language en-US
Xref csiph.com comp.lang.java.programmer:38369

Show key headers only | View raw


On 6/13/2018 05:39, siddareddy.moolam@gmail.com wrote:
>   i have tried in java :
> 
> package com.techstar.com;
> 
> import java.net.InetAddress;
> import java.net.UnknownHostException;
> 
> class IpAdress{
> 	
> public static void main (String args[]) throws UnknownHostException {
> 
> 
> //  strIp containing an IP address or a machine name
> //  strServer containing a machine name
> 
> // Get the IP address to look for as InetAddress
> 	
> 	 String strIp = "192.168.15.74";
> InetAddress ip = InetAddress.getByName(strIp);
> String strServer="";
> // Get all IP adresses associated with strServer
> InetAddress[] serverIps = InetAddress.getAllByName(strServer);
> for (int i = 0; i < serverIps.length; i++)
> {
>      if (ip.equals(serverIps[i]))
>      {
>      	System.out.println("Server ip is present" +ip);
>      }
>      else {
>      	System.out.println(" ip is not present" +ip);
>      }
>      }
>      
> }}
> 

Probably the easiest way is to try to connect to the server.

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress   present in the server or not??? siddareddy.moolam@gmail.com - 2018-06-13 03:39 -0700
  Re: How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress present in the server or not??? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2018-06-13 11:01 -0500
    Re: How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress present in the server or not??? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2018-06-13 11:06 -0500
    Re: How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress present in the server or not??? siddareddy.moolam@gmail.com - 2018-06-13 23:14 -0700
      Re: How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress present in the server or not??? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2018-06-14 13:02 -0500
        Re: How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress present in the server or not??? Arne Vajhøj <arne@vajhoej.dk> - 2018-06-14 14:09 -0400
          Re: How to give ip address as a input on java...if I give ip addrees as a input need to display ip adress present in the server or not??? Martin Gregorie <martin@mydomain.invalid> - 2018-06-14 21:40 +0000
  i need to check whether particular ip adress is up or down can anybody help me?? siddareddy.moolam@gmail.com - 2018-06-13 23:16 -0700

csiph-web