ASP编程 PHP编程 JSP编程 NET编程 CGI编程 XML编程 
Google adsense申请技巧本站核心代理域名注册主机业务 快速发布你的买卖域名买卖网站信息 1元注册 cn域名
站长每日新闻导读 √ ·推荐万网空间¥120元 150m 站长网:站长必上的网站网站联盟大全本站代理万网域名55空间120元
 2006-12-10 10:28:06

修改后的Whois查询程序

来源: 字体:[ ]
<% @Page Language="C#" %>
<% @Import Namespace="System.Net" %>
<% @Import Namespace="System.Net.Sockets" %>
<% @Import Namespace="System.Text" %>
<% @Import Namespace="System.IO" %>
<% @Import Namespace="System.Collections" %>
<html>
<head>
<title>Whois查询</title>
<LINK href="../inc/main.css" type="text/css" rel="stylesheet">
<script language="C#" runat="server">
void doQuery(Object sender, EventArgs e)
{
  String strDomain;
  String strServer;  
  //strServer = "whois.paycenter.com.cn";
  //新网的Whois,联接查询速度较快,但不是在新网注册的域名可能无法显示详细资料
  strServer = "66.150.5.140"; //whois.uwhois.com
  
  if(txtDomain2.Checked)
  { strDomain = txtDomain1.Text+txtDomain2.Text; }
  else
  {
    if(txtDomain3.Checked)
    { strDomain = txtDomain1.Text+txtDomain3.Text; }
    else
    {
      if(txtDomain4.Checked)
      { strDomain = txtDomain1.Text+txtDomain4.Text; }
      else
      {
        if(txtDomain5.Checked)
        { strDomain = txtDomain1.Text+txtDomain5.Text; }
        else
        { strDomain = txtDomain1.Text+txtDomain6.Text; }
      }
    }
  }
  
    
  String strResponse;
  bool bSuccess = DoWhoisLookup(strDomain, strServer, out strResponse);
  if (bSuccess)
  {
    txtResult.Text = strResponse;
  }
  else
  {
    txtResult.Text = "查询失败!请重试。";
  }
}

bool DoWhoisLookup(String strDomain, String strServer, out String strResponse)
{
  strResponse = "none";
  bool bSuccess = false;

  TcpClient tcpc = new TcpClient();
  tcpc.Connect(strServer, 43);
  strDomain += "\r\n";
  Byte[] arrDomain = Encoding.UTF8.GetBytes(strDomain.ToCharArray());
  try
    {
        Stream s = tcpc.GetStream();
        s.Write(arrDomain, 0, strDomain.Length);
    
        StreamReader sr = new StreamReader(tcpc.GetStream(), Encoding.UTF8);
        StringBuilder strBuilder = new StringBuilder();
        while (-1 != sr.Peek())
        {
          strBuilder.Append(sr.ReadLine()+"<br>");
        }
        tcpc.Close();
        
        bSuccess = true;
        strResponse = strBuilder.ToString();
    }
  catch(Exception e)
    {
        strResponse = e.ToString();
    }
    
    return bSuccess;
}
</script>
</head>
<body>

<form runat="server">
域名: www.<asp:TextBox id="txtDomain1" value="" runat="server" />
<asp:RadioButton id="txtDomain2" GroupName="RadioGroup1" text=".com" checked="True" runat="server" /> 
<asp:RadioButton id="txtDomain3" GroupName="RadioGroup1" text=".net" runat="server" /> 
<asp:RadioButton id="txtDomain4" GroupName="RadioGroup1" text=".org" runat="server" /> 
<asp:RadioButton id="txtDomain5" GroupName="RadioGroup1" text=".biz" runat="server" /> 
<asp:RadioButton id="txtDomain6" GroupName="RadioGroup1" text=".cc" runat="server" /> 
<asp:Button id="btnQuery" OnClick="doQuery" text="查询" runat="server" />
<BR><HR width="100%"><BR>
<asp:label id="txtResult" ForeColor="#0000FF" class="body" runat="server" />
</form>
</body>
<


网站地图 - 域名注册续费虚拟主机代理 - 交易论坛 - 网站投稿 - 广告服务 - 帮助中心 - 联系我们
Copyright ©2003-2007 www.Admin5.com All Rights Reserved