Whois Search using C # (feels good.) Previously, C + + and VB have done. Now for a C # look

Source: Internet
Author: User
Tags getstream top level domain
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 this 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 T CP 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 #"%><% @Assemb Ly 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",) {     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!"); %>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.