5,699,431 members and growing! (24,615 online)
Email Password   helpLost your password?
General Programming » Internet / Network » General     Intermediate

Creating a global Whois class

By marschills

Lookup a domain name for any tld (top level domain)
C#Windows, .NET, .NET 1.0, .NET 1.1, Win2K, WinXP, Win2003VS.NET2002, Visual Studio, Dev

Posted: 6 Dec 2003
Updated: 6 Dec 2003
Views: 37,597
Bookmarked: 24 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
8 votes for this Article.
Popularity: 3.06 Rating: 3.39 out of 5
1 vote, 12.5%
1
1 vote, 12.5%
2
0 votes, 0.0%
3
2 votes, 25.0%
4
4 votes, 50.0%
5

Introduction

I realise there is already a Whois example for C# on codeproject, in the form of an asp.net snippet. The class I've posted here encapsulates a little more functionality than that example, and is taken from a Perl script i wrote a few years back.

Details

The Whois class has one main method, Lookup(domain). From this, the class works out what whois server should be used for the domain lookup. This is done by a trick taken from the Perl script, the service is provided by whois-servers.net, hosted by CenterGate. From performing a dns lookup on the domain name's tld (e.g. .com for mydomain.com), attached to .whois-servers.net, you're provided with the address of the whois server for that domain, if one exists.

I've built into the class, the ability to provide your own whois server, via the WhoisServer property. I've also added checks for a few domain names which don't provide free whois servers, and the .tk domain which does, but isn't on the whois-servers.net service.

The class performs the lookup, and raises an event, LookupComplete when it's finished, passing a WhoisEventArgs class with it, which provides the results of the lookup, and the whois server that was used.

To check whether a domain is taken or not, is up to you - you'll have to parse the string provided in the WhoisInfo property of the WhoisEventArgs class.

The example project is a small windows forms application, to demonstrate how to use the class. The class doesn't cater for non-resolving whois servers at present, it could perhaps do with a few more lines of error trapping in this area.

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

marschills


London based C# programmer.

I maintain my own pet C# site http://www.sloppycode.net in my spare time.
Occupation: Web Developer
Location: United Kingdom United Kingdom

Other popular Internet / Network articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 7 of 7 (Total in Forum: 7) (Refresh)FirstPrevNext
GeneralSocket Exception Unhandled - No such host knownmemberSniper16719:36 18 Jul '07  
GeneralRe: Socket Exception Unhandled - No such host knownmembersmallguy781:10 23 Jul '07  
GeneralWhois class implementationmemberSyst3m Crash3r 4807:27 30 May '06  
GeneralRe: Whois class implementationmembersmallguy781:16 14 Nov '06  
GeneralC# IPHostEntry Cache???memberkvnsdr18:56 20 Aug '04  
GeneralWhois Servermemberyoussef elmansouri0:25 9 Dec '03  
GeneralRe: Whois Servermembersmallguy788:18 9 Dec '03  

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

PermaLink | Privacy | Terms of Use
Last Updated: 6 Dec 2003
Editor: Nishant Sivakumar
Copyright 2003 by marschills
Everything else Copyright © CodeProject, 1999-2008
Web19 | Advertise on the Code Project