Network Tool Whois in C#


'WHO-is' is a Network Tool or a Query. In general, it come in practice to get the hidden details about the Host like Domain Name, IP Address and details about the person/organization who is really hosting.

User-Interface Design

  1. 1 Combo Box
  2. 2 Text Box
  3. 1 Button
  4. 2 Label
  5. 1 Progress Bar


Put your Combo Box, Text Box and Button inside a Group Box. Next, put a Multi-Line Text Box just aside that group box. And, rests are the Labels and Progress Bar which are not that tough to drag-drop from the toolbox.
After, you're designing effort may you get the result which look similar to the following window. 


Background  Details

1. Combo Box (cmbServer)

cmbServer contain three items you may add it using c# code or by its property window. Name it as cmbServer. Right now, I prefer Property Window

Click on 'Items' and add three values in individual line.


  • [Default]

2. Text Box  (txtHostName)

Drag a text box and put in its corresponding location. It is as easy, as you have done earlier. Name it as txtHostName. From, here we get the host name. May be,, or any thing.

3. Button (btnLookUp)

 Put a button on the form and name it as btnLookUp and Text must be Look Up or whatever you wish.

4. Multi-Line Text Box (txtxResponse)

In this TextBox we will store the fetched data from whois server. That's why, it must be multi line with Horizontal Bar. Name this control as txtxResponse.

Now, there is need to create the text box as multi line. So, click on the little arrow on the right corner of the text box. And, check the MultiLine Text Box.

5. Progress Bar (progressbar1)

Put it just below the text box and rest labels and the picture box are left for you.
C# Code :

First, add some namespace.

using System.IO;

using System.Net.Sockets;
Then create some Reference variables in Form class,

TcpClient tcpWhois;

NetworkStream nsWhois;

BufferedStream bfWhois;

StreamWriter strmSend;

StreamReader strmRecive;
In Form() Constructor, Define Progress Bar values,

progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
 In Form_Load() event,

Double Click on your active form.

Here, we define the default index of Combo Box.
cmbServer.SelectedIndex = 0;
Now, we will define some actual codes.

In LookUp Button, Click event has,

  tcpWhois = new TcpClient(cmbServer.SelectedItem.ToString(), 43);

// We assigned WHOis  Server(from comboBox) and its corresponding Port(43) to the TcpClient Constructor.


nsWhois = tcpWhois.GetStream(); // Setup the Stream of Tcp client using GetStream() method

bfWhois = new BufferedStream(nsWhois); // Initializing the Buffer

strmSend = new StreamWriter(bfWhois);


//Sending the Server & Host Name using StreamSend class

strmSend.Flush(); // Clear the buffer

txtxResponse.Clear(); // clear the text box



        // Turn to Recive the data from Server

        strmRecive = new StreamReader(bfWhois);

        string response;

        // variable, which 'll store the response from server.

        //Continue the LOOP till it comes to the end (null)     

         while ((response = strmRecive.ReadLine()) != null)


              //at every response append to New line using "\r\n"

              txtxResponse.Text += response + "\r\n";

              //increase the value of Progress Bar :D

              if (progressBar1.Value < 100)

              progressBar1.Value += 10;





           //FOUND any exception

           MessageBox.Show("WHOis Server Error :x","Error");




            MessageBox.Show("No Internet Connection or Any other Fault", "Error");







              // Close the stream





               //DO nothing


At End

Ultimately we have a working window which takes the Host Name as Input and show the Whois Details about the Host.