CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Posts
    31

    Question all connecting local ip addresses

    Hi,

    I am new to AD and networking,

    I'd like to get all online clients'IP addresses (that be e.g \\192.168.1.xxx\Client1, \\192.168.1.xxx\Client2, \\192.168.1.xxx\Client3 , etc)

    My code in Linux is
    Code:
    int main() 
    { 
      const char* const host = "computername" ; 
      const hostent* host_info = 0 ; 
      host_info = gethostbyname(host) ; 
     
      if(host_info) 
      { 
        std::cout << "host: " << host_info->h_name << '\n' ; 
     
        for( int i=0 ; host_info->h_addr_list[i] ; ++i ) 
        { 
          const in_addr* address = (in_addr*)host_info->h_addr_list[i] ; 
          std::cout << " address: " << inet_ntoa( *address ) << '\n' ; 
        } 
      } 
      else herror( "error" ) ; 
    }
    I'd like to do this in a pure MFC application, what api functions should I look up ?

    Thank you.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: all connecting local ip addresses

    Did you try using the same code you used in Linux?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2010
    Posts
    31

    Unhappy Re: all connecting local ip addresses

    Thank you for your reply,
    I didn't try it in Windows's console application. I 've been looking for a class or functions if available in MFC to do similar tasks.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: all connecting local ip addresses

    There is no any MFC wrapper for gethostbyname function.
    The same - for inet_ntoa
    Victor Nijegorodov

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured