Checking for valid (and working) address

(sorry if i posted in the wrong forum... i didn't found any that suits better my problem)
that's the question: i have a string and need to check if it's a valid host name/ip address and also check if it's up and running at the moment. to solve the host name, i have the following code:
try {
URL url = new URL(sURL);
HttpURLConnection uc = (HttpURLConnection) url.openConnection() ;
uc.setRequestMethod("GET") ;
uc.connect();
uc.getResponseMessage();
catch (IOException ioe) {
//wrong url/not working
but it doesn't work with ip addresses. Someone suggested me to use InetAddress.isReachable(int), but it's only avaliable since Java 1.5, and i must use 1.4. Another way around would be to use InetAddress.get(Canonical)HostName(), but it may fail even with a valid ip address, and i can't allow that.
can someone give me a hand?
thanks!

(sorry if i posted in the wrong forum... i didn't
found any that suits better my problem)
that's the question: i have a string and need to
check if it's a valid host name/ip address and also
check if it's up and running at the moment. to solve
the host name, i have the following code:Easy - it isn't possible at all.
If and only if you were to use ICMP (which you can't in 1.4 using just java) and if and only if the target computer responded to ICMP then you could use that.
That is seldom very useful because generally one doesn't care if a computer responds to ICMP. What they need to know is if the computer is actually doing what it is supposed.
For example if you have an http server, what you care about is if it is actually handling http requests. (The computer can be up and not handling http requests.)
Not to mention of course that a host name requires that the DNS server respond to it first. And just because the DNS server is failing it doesn't mean that the target PC is failiing.
But if you really want to do nothing but ICMP then you can use Runtime.exec() and an OS specific command (usually 'ping') to do just that.

Similar Messages

  • Checking for valid (and working) host name/ip

    hi
    i have posted this in other topic, but i think it was the wrong forum... so if you wanna try to help me...
    http://forum.java.sun.com/thread.jspa?threadID=603987

    no that was the right forum, although it gets low traffic. This is not the right forum for that quesiotn. Your best bet is the "Java Programming" or "New To Java" forums.

  • Select between home and work addresses for Autofill

    I've searched and browsed for this and I think I know the answer but I want to check before I submit a feature request to Apple and give up for now:
    Can we choose between home and work addresses on our contact card when we have Safari perform autofills?
    I think the answer is no, that only the first address listed in our contact card is used.
    It would be most useful to be able to select the address used. Many of us have our contacts synced now between home and work computers and some of us are allowed to do occassional home business on work computers, or use our home computers for work.
    I experimented with an alternative. I set up two contacts for myself, a home contact and a work contact. They both use my name. I find that in the Contacts app I can select which card is "my card", and that will be used by autofill. But I have to open Contacts to switch "my card" to use that for autofill. It would be more useful if Safari would simply provide a way to switch between home and work contact info on the fly, or at least switch between cards.
    Am I missing anything?

    Thanks, fruhulda. I do have both my work and home address on my card in
    Address Book, and I agree that I should be able to choose which to use to fill in fields on a fax form. My question is how do I do that. I want to send a fax; I want it to feature my home information, but it's the work information that's automatically filling in. How do I change that?

  • Time capsule first said the back up was delayed no it won't connect to my home network. my internet is working fine and so is everything else but when i try to connect to the time capsule it says to check my server and ip address help!

    time capsule first said the back up was delayed, now it won't connect to my home network. my internet is working fine and so is everything else but when i try to connect to the time capsule it says to check my server and ip address and if it continues to contact system administrator.. i didnt change anything, please help!

    Lion networking.. just need to reboot everything.. modem TC and the clients.. then it will work.. Sometimes just the TC is enough.. sometimes just the computer. .. Vista golden networking award.. did you turn it off and on again??

  • TS3899 email was working then all of a sudden its "checking for updates" and wont update

    My Iphone 4s was working fine and now I can't get the email to update. I have deleted my account and it still isn't working. Everything else internet wise is working, just not the email. Any ideas?

    I can send emails, but when it is "checking for mail" and the circle is moving, it never stops, just keeps searching. I checked my email from my computer and I had 10 new emails, so I know they are waiting for me, I can't even retrieve emails that I have read and are still on my account. It won't bring up the accounts at all

  • The download of icloud control  panel v2.0 does not work. I have no box to check for calendar and contaks. Whats wrong?

    The download of icloud control panel v2.0 does not work. I habe no box to check for calendar and contacts. Whats wrong?
    Thanks Chris

    Hi, I came across the same problem and was not able to open any iCloud folders on Outlook, and iCloud was continusly asking to repair the iCloud Control Panel. Got the issue fixed by following the steps on the link http://somanytips.com/fix-icloud-error-repair-the-icloud-control-panel-to-use-ic loud-with-outlook/

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • Why yahoo/gmail retrieval and facebook app so so slow when in WIFI. But using the internet to check for emails and facebook is fast using the same WIFI connection??

    Why yahoo/gmail retrieval and facebook app so so slow when in WIFI. But using the internet to check for emails and facebook is fast using the same WIFI connection??

    Hi SandyS_VZW,
    Yes tried resetting the wifi connection and problem still persist.
    Here it is...to make it clear. Connected thru the same wifi at home...
    -> emails (yahoo/gmail) and facebook WEBSITES are working fine and fast when using/accessing thru a browser (chrome/samsung browser) - no problem with this.
    -> emails (yahoo/gmail) and facebook APP is soooooo sloooww (thru the App). Slow I mean comparing it to using their browser/websites... news feeds/emails refreshing so quickly but not when using the APP installed in Samsung Galaxy Note 4. Slow like - It will take around 5-10minutes just to get your emails and news feed refreshed.
    THIS HAPPENS ONLY WHEN CONNECTED THRU A WIFI which has a speed of 10-20mb. It is not happening when connected to the network data/plan.
    My wife has the same Samsung Galaxy Note 4 (coming from different provider at&t) - same setup (emails, fb app), same wifi connection, but she's not experiencing anything like it.
    Not sure why, I dont want to believe that while connected to a WIFI, Verizon is restricting anything and ******* me off to make me switch to my data plan connection everytime - which is Unfair!
    Was there a known issue similar about this case?
    thanks,

  • Business Partner - Error for validity periods of addresses R11244

    We are using ECC transaction BP, and we are facing the error "Error for validity periods of addresses" when we tried to change a business Partner.
    Error for validity periods of addresses
    Message no. R11244

    Check the following notes:-
    1)  Note 882726 - SAP BP: Error message R11 244 (BP Transaction + BAPIs)
    2)  Note 1380576 - ECC BP to CRM BP address repln fails due to validity periods
    thanks
    G. Lakshmipathi

  • Patch 1.1.3 - check for updates not working?

    Hi all;
    I can't get the check for updates to work.
    Help/About shows I am running version 1.1.2.25, build main 25.79
    Help/check for updates has the "Official Oracle extensions and Updates" and the "Oracle SQL Developer" boxes checked
    When I search, it says no updates available. Do I need need to add another Update Center?
    I'm running it on Windows XP, SP2
    Thanks
    Al

    Try Help -> About -> Extensions and check the version
    of Oracle SQL Developer. If this shows 1.1.3.27.66,
    then you have already upgraded to 1.1.3.
    Unfortunately, the version details on Help -> About
    -> About are the details of the last full install -
    they are not updated when upgrading via Check for
    Updates.That is it. Thank you very much for your help
    Al

  • I have installed itunes 10.7 several times.  All goes well.  After reboot, I go into itunes and check for updates and it says I need to download the update 10.7! (And so cant sync with my Iphone)

    I have installed itunes 10.7 several times, all goes well. After reeboot, I go to check for updates and it still wants to update to version 10.7! I cant sync to my iphone4 because I get an error message saying I need version 10.6.3 or later. Help

    Thank you for getting me started on the track by mentioning "Revo" Uninstaller.  The results of "Revo" spoke volumns on why a successful install of ITunes is so difficult to achieve.  It is the evil "BONJOUR".
    I then tripped upon the following site by Apple and the detailed directions (I read, printed, re-read and followed the instructions.  It was intense) brought a successful ITunes, Quick Time and the lovely Bonjour home.  Thank you for the start JD42.
    http://support.apple.com/kb/HT1923

  • My MacBook Pro is running VERY slow. I am constantly getting pop-ups and now I got one that says my computer may be infected. What do I do to check for viruses and or remove them if there is one?

    What do I do to check for viruses and or remove them if there is one? I have never had a problem with my mac until now. It is running VERY slow

    This is what it came up with.... any ideas?
    EtreCheck version: 1.9.11 (43) - report generated May 27, 2014 at 11:07:36 PM CDT
    Hardware Information:
              MacBook Pro (15-inch, 2.53GHz, Mid 2009)
              MacBook Pro - model: MacBookPro5,4
              1 2.53 GHz Intel Core 2 Duo CPU: 2 cores
              4 GB RAM
    Video Information:
              NVIDIA GeForce 9400M - VRAM: 256 MB
    System Software:
              OS X 10.9.3 (13D65) - Uptime: 1 day 23:26:50
    Disk Information:
              Hitachi HTS545025B9SA02 disk0 : (250.06 GB)
                        EFI (disk0s1) <not mounted>: 209.7 MB
                        Macintosh HD (disk0s2) / [Startup]: 249.2 GB (20.75 GB free)
                        Recovery HD (disk0s3) <not mounted>: 650 MB
              MATSHITADVD-R   UJ-868 
    USB Information:
              Apple Inc. Built-in iSight
              Apple Internal Memory Card Reader
              Apple Inc. Apple Internal Keyboard / Trackpad
              Apple Computer, Inc. IR Receiver
              Apple Inc. BRCM2046 Hub
                        Apple Inc. Bluetooth USB Host Controller
    Gatekeeper:
              Anywhere
    Kernel Extensions:
              [not loaded] com.rim.driver.BlackBerryUSBDriverInt (0.0.39) Support
              [not loaded] com.rim.driver.BlackBerryUSBDriverVSP (0.0.39) Support
    Problem System Launch Daemons:
              [failed] com.apple.wdhelper.plist
    Launch Daemons:
              [loaded] com.adobe.fpsaud.plist Support
    User Launch Agents:
              [loaded] com.adobe.ARM.[...].plist Support
              [loaded] com.macpaw.CleanMyMac.helperTool.plist Support
              [loaded] com.macpaw.CleanMyMac.trashSizeWatcher.plist Support
              [loaded] com.macpaw.CleanMyMac.volumeWatcher.plist Support
              [running] com.whitesmoke.uploader.plist Support
    User Login Items:
              iTunesHelper
              AdobeResourceSynchronizer
    Internet Plug-ins:
              JavaAppletPlugin: Version: 14.9.0 - SDK 10.7 Check version
              FlashPlayer-10.6: Version: 13.0.0.214 - SDK 10.6 Support
              Default Browser: Version: 537 - SDK 10.9
              AdobePDFViewerNPAPI: Version: 11.0.06 - SDK 10.6 Support
              AdobePDFViewer: Version: 11.0.06 - SDK 10.6 Support
              Flash Player: Version: 13.0.0.214 - SDK 10.6 Support
              QuickTime Plugin: Version: 7.7.3
              Silverlight: Version: 5.1.10411.0 - SDK 10.6 Support
              iPhotoPhotocast: Version: 7.0
    Safari Extensions:
              WhiteSmoke: Version: 1.0.0.1
              Vidx: Version: 2.0
              DivX Plus Web Player HTML5 <video>: Version: 2.1.2.145
    Audio Plug-ins:
              BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
              AirPlay: Version: 2.0 - SDK 10.9
              AppleAVBAudio: Version: 203.2 - SDK 10.9
              iSightAudio: Version: 7.7.3 - SDK 10.9
    iTunes Plug-ins:
              Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
    User Internet Plug-ins:
              Move-Media-Player: Version: npmnqmp 071801000001 Support
              fbplugin_1_0_1: Version: (null) Support
    3rd Party Preference Panes:
              Flash Player  Support
    Time Machine:
              Time Machine not configured!
    Top Processes by CPU:
                  12%          DashboardClient
                   6%          coreaudiod
                   6%          WindowServer
                   5%          repair_packages
                   3%          VLC
    Top Processes by Memory:
              549 MB          repair_packages
              143 MB          com.apple.WebKit.WebContent
              131 MB          Safari
              119 MB          installd
              94 MB          mds_stores
    Virtual Memory Information:
              809 MB          Free RAM
              1.82 GB          Active RAM
              224 MB          Inactive RAM
              630 MB          Wired RAM
              3.66 GB          Page-ins
              207 MB          Page-outs

  • Duplication check for Lead and Contact

    Hi,
    Can i confirm that, there is no duplication check for Lead and Contact during the new reacord adding?
    I also realise that during the Lead convertion, CRMOD also never check for duplication even i have existing contact available?
    Is there anyway for us to activate the duplication check during the Lead convertion?
    Regards,
    SK

    SK,
    System can check duplicate if you add external id for record (Lead and Contact).
    For more information please refer topic 'About record duplicates and external ids' on page no.1303 of OnDemand help.
    Hope this helps.
    Santosh

  • When firefox checking for updates and updates found but due to proxy restrictions it unable to download the updates then it continue trying to download that and this time it creating problem on running javascript

    When firefox checking for updates and updates found but due to proxy restrictions it unable to download the updates then it continue trying to download that and this time it creating problem on executing javascript and raising errors.

    What are the error messages you are seeing?

  • Why won't my iMac print consistantly to my compatible HP 6500A? I've checked for updates and downloaded the lasted software...still can't print. All my other Mac devices find the printer but the iMac is hit and miss. I'm operating the Mac OS X Lion 10.7.

    Why won't my iMac print consistantly to my compatible HP 6500A? I've checked for updates and downloaded the lasted software...still can't print. All my other Mac devices find the printer but the iMac is hit and miss. I'm operating the Mac OS X Lion 10.7.

    When you say hit and miss do you mean sometimes you print a whole document with no problems, or do you mean each document has problems? This is from HP's website for your printer:
    Your sig says 10.6.7 but your message says 10.7. So if it's really Lion, this printer isn't officially supported. Elsewhere on HP's site it says updated drivers will be available on your Mac via Software Update. Have you run that recently?

Maybe you are looking for