www.webdeveloper.com
Results 1 to 6 of 6

Thread: host name ping

  1. #1
    Join Date
    Jun 2006
    Posts
    204

    host name ping

    If I have a computer named computer_test .. How would I write a program to return a value of "online" if it is pinged?

    I need to be able to ping the computer from within my program.
    Thanks for the help.
    Matt

  2. #2
    Join Date
    Jun 2006
    Posts
    204
    Anyone have any information on this?
    Thanks for the help.
    Matt

  3. #3
    Join Date
    Feb 2005
    Location
    Tauranga
    Posts
    2,062
    something like

    PHP Code:
    <?php
    echo(chkServer('www.server.com''80'));


    function 
    chkServer($host$port){  
        
    $hostip = @gethostbyname($host);
        if(
    $hostip == $host){
            echo 
    "Server is down or does not exist";
        }else{
            if(!
    $x = @fsockopen($hostip$port$errno$errstr5)){
                echo 
    "Off Line";
            }else{
                echo 
    "Online";
                if(
    $x){
                    @
    fclose($x);
                }
            }
        }
    }
    ?>

  4. #4
    Join Date
    Jun 2006
    Posts
    204
    Will that also work for computers on a network using the computer's name?
    Thanks for the help.
    Matt

  5. #5
    Join Date
    Feb 2005
    Location
    Tauranga
    Posts
    2,062
    pass, try it, use the ip address.

  6. #6
    Join Date
    Jun 2006
    Posts
    204
    Pass.. as in you do not know? or pass...can't do it? My IP's change
    Thanks for the help.
    Matt

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles