WHOIS to verify if a domain is free or not

N

NGLurker

Hi all. I'm trying to deveolp a whois function to verify if a domain is free
or not.
At the moment I use this code:

**********************************************************************
<% @Page Language="C#" %>
<% @Import Namespace="System.Net.Sockets" %>
<% @Import Namespace="System.Text" %>
<% @Import Namespace="System.IO" %>
<%
TcpClient tcpc = new TcpClient();
try
{
tcpc.Connect("whois.internic.com", 43);
}
catch(SocketException ex)
{
Response.Write(ex.ToString());
Response.End();
}

String strDomain = "somedomainsomewhere.com\r\n";
Byte[] arrDomain = Encoding.ASCII.GetBytes(strDomain.ToCharArray());

Stream s = tcpc.GetStream();
s.Write(arrDomain, 0, strDomain.Length);

StreamReader sr = new StreamReader(tcpc.GetStream(), Encoding.ASCII);
string strLine = null;

while (null != (strLine = sr.ReadLine()))
{
Response.Write(strLine + "<br>");
}

tcpc.Close();
%>

*******************************************************************

And I get a long message, such as:

*******************************************************************
Whois Server Version 1.3

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

No match for "fgsdgdfgdfgdg.com".

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the
expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: <CUT>
******************************************************************************

Is there any way to directly verify if a domain is free, or must I analyze
this string and look for an occureny of the "no match" text?!?

Thanks in advance!
 
D

Davide Vernole [MVP]

NGLurker said:
Hi all. I'm trying to deveolp a whois function to verify if a domain
is free or not.
[CUT]
Is there any way to directly verify if a domain is free, or must I
analyze this string and look for an occureny of the "no match" text?!?

Thanks in advance!

Why not do you use a web service like this:
http://ws.cdyne.com/whoisquery/whois.asmx?op=GetWhois to retrieve the
information ?

Here you could find more web service that offer WHOIS functions:
http://uddi.microsoft.com/search/frames.aspx?frames=true&search=b561a679-3b8b-4ce1-8d5d-86b0f69f6dc9
 
N

NGLurker

Why not do you use a web service like this:

For two reasons.
The first one is that I would like to write the code by myself (even if at
the moment I'm using something found on the web) :)
The second one is that I would like to be indipendent. What if a certain
point the owner of that webservice stops providing it?

Anyway looking inside the string does not seem a great thing :-/
 
K

Ken Dopierala Jr.

Hi,

I'm afraid your out of luck. You can either use the web service that was
suggested to you, or you can parse the string. Why do you want to be able
to do this? I take it you are not reselling domain names. If you were, you
would have direct access to a database that would let you know whether or
not those domains are available. If this is a commercial app, where you are
planning on making a profit, then why not just sign up to sell domain names
too? Then you could gain access to the database as well as sell domain
names on the side. Good luck! Ken.
 
N

NGLurker

I'm afraid your out of luck. You can either use the web service that was
suggested to you, or you can parse the string.

Ok, even if parsing the string is so "unelagant" :)
If this is a commercial app, where you are
planning on making a profit, then why not just sign up to sell domain
names
too? Then you could gain access to the database as well as sell domain
names on the side.

Because the app is about developing web sites, and checking if a domain is
free or not is just an add-on for the costumer, who can order telling me: "I
want you to develop a site for me, with this domain", then I'll buy the
domain somewhere.
Good luck!

OK, thank you. Going to parse the string!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top