I need to do a whois towards a whois lookup. The website i've created cannot do all the requests, since it might be blocked.
So, I need to send the visitors ip-adress in the lookup. This is the code i have at the moment:
var name = "testadress.no";
var userIp = Request.ServerVariables["REMOTE_HOST"];
const string whoisServerAddress = "whois.host.no";
var strDomain = "-c utf-8 "+ name + "\r\n";
var bytDomain = Encoding.UTF8.GetBytes(strDomain.ToCharArray());
var tcp = new TcpClient();
tcp.Connect(whoisServerAddress, 43);
var s = tcp.GetStream();
s.Write(bytDomain, 0, strDomain.Length);
var sr = new StreamReader(tcp.GetStream(), Encoding.UTF8);
var strLine = "";
var result = new List<string>();
while (null != (strLine = sr.ReadLine()))
{
result.Add(strLine);
}
tcp.Close();
return result;