online checker

This is a discussion on online checker within the Windows Programming forums, part of the Platform Specific Boards category; i'm using winsock, is there a way to check if a machine is online without using ping, i would use ...

  1. #1
    joe90004
    Guest

    online checker

    i'm using winsock, is there a way to check if a machine is online without using ping, i would use ping but it seems like to much work to code so i am looking for another method. if anyone thinks ping is ........ then explain otherwise any other way of checking would be good. Thank you.

  2. #2
    Unregged
    Guest
    What about to resolve the adress to www.yahoo.com using GetHostByName (Winsock)

    Doesn't use Ping! Needs Internet connection to do it.

  3. #3
    joe90004
    Guest
    no.....

    I don't want to check if my machine is online, I want to check if a remote machine is online, that's why i was whining about ping cos it can do it but i'm not sure how to implement that into my program and it seems complicated. so, if anyone knows any other methods to check whether a remote machine is online, please say, ty.

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    254
    Originally posted by joe90004
    no.....

    I don't want to check if my machine is online, I want to check if a remote machine is online, that's why i was whining about ping cos it can do it but i'm not sure how to implement that into my program and it seems complicated. so, if anyone knows any other methods to check whether a remote machine is online, please say, ty.
    you could try just connecting to a port you know is open on that machine... that would tell you it was online...

  5. #5
    joe90004
    Guest
    That does'nt seem to work, it always outputs "No Error".

  6. #6
    joe90004
    Guest
    I know all that, here's the code i used in MSVC++ 6 :
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <errno.h>
    #include <winsock.h>
    
    int main( int argc, char *argv[] )
    {
      int is_ip;
      struct in_addr address;
      if( argc != 2 ) return 1;
      is_ip = inet_addr( argv[1] );
      if( is_ip != -1 ) {
        address.s_addr = is_ip;
        if( gethostbyaddr( ( const char* )&address, sizeof( struct in_addr ), AF_INET )
            == NULL ) {
          fprintf( stderr, "gethostbyaddr() failed" );
          return 1;
        }
      } else {
        if( gethostbyname( argv[1] ) == NULL ) {
          fprintf( stderr, "gethostbyaddr() failed" );
          return 1;
        }
      }
      puts( "Alright, reachable." );
      return 0;
    }
    and... all i seem to get is the failure msg. I run it like so in the console:
    >onlinecheck cprogramming.com
    OR
    >onlinecheck [IP]
    which always results in failure. Any ideas?

  7. #7
    joe90004
    Guest
    ok, it works, ty.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error in distributing .exe online
    By GamesSmash in forum C++ Programming
    Replies: 31
    Last Post: 11-27-2007, 04:41 PM
  2. 2D Spaceship shooter online - Need 2 keen programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 05-19-2005, 08:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21