Hack Forums
[C#] Looking up Whois Info the Right Way - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Looking up Whois Info the Right Way (/showthread.php?tid=5441106)



Looking up Whois Info the Right Way - mrkoolaid - Oct 22, 2016

You can find a nice Whois Server list on Github

Add Using statement:
Code
using System.Net;
using System.Net.Sockets;

Global Declarations:
Code
public string whois_server;
public int whois_port;
public TcpClient client;
public string dns_qry;

Form Load Event:
Code
whois_port = 43;
whois_server = textBox1.Text;
dns_qry = string.Empty;

Tetxbox 2 Keypress Event:
Code
switch ((Keys)e.KeyChar)
{
    case Keys.Enter:
        client = new TcpClient();
        textBox3.Text = "";

        client.Connect(whois_server, whois_port);
        dns_qry = textBox2.Text + "\r\n";
        byte[] qry_bytes = Encoding.ASCII.GetBytes(dns_qry.ToCharArray());
        Stream dns_strm = client.GetStream();
        dns_strm.Write(qry_bytes, 0, qry_bytes.Length);
        StreamReader rdr = new StreamReader(dns_strm, Encoding.ASCII);
        while (rdr.ReadLine() != null)
        {
            textBox3.Text += rdr.ReadLine() + Environment.NewLine;
        }

        rdr.Close();
        dns_strm.Close();
        client.Close();
        break;
}



* - Ninja - Oct 22, 2016

And what do we enter in TextBox1?


* - abratar - Oct 23, 2016

(Oct 22, 2016 04:37 PM)Ninja Wrote:  And what do we enter in TextBox1?

the host i guess?


* - BahNahNah - Oct 23, 2016

Quote: while (rdr.ReadLine() != null)
{
textBox3.Text += rdr.ReadLine() + Environment.NewLine;
}


I think you are skipping half of the lines.