最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Whois search using C#(感觉不错。以前C++和VB的都做过。现在换一个C#的看看
时间:2022-07-02 12:02:58 编辑:袖梨 来源:一聚教程网
IntroductionQuite often you want to know who owns a given domain. To obtain the registry information, you go to the respective registry and start a so called WHOIS query (lookup). The trick is that you have to know which registry is responsible for which TLD (Top Level Domain).
The database is the so called WHOIS database and it has one distinct property: it provides us with a query interface via TCP port 43! And as the .NET framework provides us with the TCPClient class, we can use this interface to directly obtain our data The following example is a minimal implementation of a WHOIS lookup (whois.aspx): <% @Page Language="C#" %><% @Assembly Name="System.Net" %><% @Import Namespace="System.Net.Sockets" %><% @Import Namespace="System.Text" %><% @Import Namespace="System.IO" %><%TCPClient tcpc = new TCPClient();if (0 == tcpc.Connect("whois.networksolutions.com", 43)){ String strDomain = "microsoft.com "; 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); while (-1 != sr.Peek()) { Response.Write(sr.ReadLine()); } tcpc.Close();}else{ Response.Write("Could not connect to WHOIS server!");}%>
The database is the so called WHOIS database and it has one distinct property: it provides us with a query interface via TCP port 43! And as the .NET framework provides us with the TCPClient class, we can use this interface to directly obtain our data The following example is a minimal implementation of a WHOIS lookup (whois.aspx): <% @Page Language="C#" %><% @Assembly Name="System.Net" %><% @Import Namespace="System.Net.Sockets" %><% @Import Namespace="System.Text" %><% @Import Namespace="System.IO" %><%TCPClient tcpc = new TCPClient();if (0 == tcpc.Connect("whois.networksolutions.com", 43)){ String strDomain = "microsoft.com "; 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); while (-1 != sr.Peek()) { Response.Write(sr.ReadLine()); } tcpc.Close();}else{ Response.Write("Could not connect to WHOIS server!");}%>
相关文章
- 《原神》5.2卡池抽取建议 11-14
- 《原神》5.2版本新怪物介绍 11-14
- 《原神》希诺宁增伤触发方法 11-14
- 《原神》循音觅奇活动入口 11-14
- 《原神》循音觅奇兑换码获取方法 11-14
- 《原神》花羽会活动飞行技巧介绍 11-14