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!
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!