Click here to Skip to main content
6,595,444 members and growing! (18,414 online)
Email Password   helpLost your password?
General Programming » Internet / Network » General     Intermediate

WhoIS Class for MFC

By Ed Dixon

A simple MFC class for WhoIS processing for the Internet.
VC6, MFC, Dev
Posted:29 Feb 2000
Views:65,771
Bookmarked:31 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
16 votes for this article.
Popularity: 5.46 Rating: 4.54 out of 5
1 vote, 14.3%
1

2

3
1 vote, 14.3%
4
5 votes, 71.4%
5
  • Download demo project - 44 Kb
  • Sample Image - Whois.jpg

    This is a simple MFC class for Internet-based WhoIs processing. WhoIs is an internet function to determine information about specific IP addresses and domain names. A number of companies, such as NetworkSolutions and Internic, keep WHOIS databases online at all times. While many freeware applications exist to display this data, there is little information or code available that actually does it.

    Many applications need access to this information, and this class provides a simple way to query these databases. The code to use this class to access this information would look like the following:

    // Create class instance
    
    CWhoIsClass whoIs;
    
    // Set address to be queried
    
    CString szAddress = "Microsoft.com";
    
    // Call actual function
    
    CString szResult = whoIs.WhoIs(szAddress);
    

    There are only two public functions for the class:

    CString WhoIs(LPCSTR szAddress);
    void SetWhoIsServer(LPCSTR szServerName);
    

    The first is used to obtain the WhoIs information. The data is returned as a string that is typically a few hundred characters.

    The second is used to change WhoIs servers. The program defaults to the whois.internic.net server. You can change it to whatever whois server best fits your needs. The Internic and Network Solutions servers host mostly US sites. Other servers exist to handle military address and international addresses. You should probably expect to query two or more servers to obtain the best information.

    When querying a whois server, you can request either domain name information (eg. microsoft.com) or IP address information (eg. 216.98.67.204). For example, the following would be valid address queries:

    whois("microsoft.com")
    whois("codedeveloper.com")
    

    but

    whois("www.microsoft.com")
    

    would be an invalid query request.

    Most whois servers appear to accept the domain portion (minus the "www." part) and return valid information. The query syntax for IP address requests varies by whois server The whois.internic.net server accepts pure IP address queries. The whois.networksolutions.com server however requires that the word "host" preceed the IP portion. If you use the network solutions whois server, which sometimes returns more complete information, your queries would have to take the following form:

    whois(host 216.98.67.204)
    

    If the "host" part is missing, no data will be returned with using the whois.networksolutions.com server.

    Using the code in your project also requires you include the source and header files for the CWhoIsClass. This would usually look like this:

    #include "WhoIsClass.h"
    
    #include "WhoIsClass.cpp"
    
    

    The code was compiled with VC++ 6.0, but should work with earlier versions as well.  It uses MFC sockets for processing, and therefore requires a AfxSocketInit() call prior to class use. It assumes a connection to the Internet already exists.

    That's it. Not very complicated, but it solved my problem. Perhaps it will help others as well.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Ed Dixon


    Member

    Occupation: Web Developer
    Location: United States United States

    Other popular Internet / Network articles:

    Article Top
    You must Sign In to use this message board.
    FAQ FAQ 
     
    Noise Tolerance  Layout  Per page   
     Msgs 1 to 13 of 13 (Total in Forum: 13) (Refresh)FirstPrevNext
    GeneralNew whois server URL Pinmemberdimag8:57 30 May '07  
    Generalbeginer Pinmemberdnqhung21:31 12 Jun '04  
    GeneralCWhoIsClass::WhoIs Bug Pinmemberqiek19:30 19 Feb '04  
    GeneralNeat !! PinmemberWREY0:05 13 Apr '03  
    GeneralUnable to use IP Address PinmemberM.Fletcher20:11 6 Jun '02  
    Generalserver to connect to get info Pinmemberpankaj22:59 24 Sep '01  
    GeneralRe: server to connect to get info PinmemberLaurent Sarrazin3:17 1 Oct '01  
    GeneralRe: server to connect to get info PinmemberYaoer17:19 16 Jan '02  
    GeneralThe App Runs only with MFC42D.dll PinsussSujatha Bhandari4:41 3 Jun '00  
    GeneralRe: The App Runs only with MFC42D.dll Pinmemberse-hyung, kim5:07 27 Jun '01  
    GeneralRe: The App Runs only with MFC42D.dll PinmemberEd Dixon5:10 27 Jun '01  
    GeneralWhois Class PinsussDick Adams5:19 6 Mar '00  
    GeneralRe: Whois Class PinsussEd Dixon18:44 6 Mar '00  

    General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    PermaLink | Privacy | Terms of Use
    Last Updated: 29 Feb 2000
    Editor: Valerie Bradley
    Copyright 2000 by Ed Dixon
    Everything else Copyright © CodeProject, 1999-2009
    Web22 | Advertise on the Code Project