Eric Bergman-Terrell's Blog

Ruby on Rails Versus ASP.NET MVC: WHOIS
November 22, 2011

As of yesterday, this site is hosted by a new hosting provider (site5). Previously, the website was written in ASP.NET MVC2, running on Windows, using MS SQL Server. It now runs on Linux, using the MySQL database. Please report any website issues to me.

I didn't re-engineer the website because of any flaws in the previous environment. I just wanted to "kick the tires" on Rails, and see what all the fuss is about. So far it's been a lot of fun!

My website includes a WHOIS utility. WHOIS is a mechanism to look up domain registration information.

The following is the Ruby and .NET WHOIS code. Note, the Ruby implementation is very basic. For instance, it relies on whatever default timeouts are in effect.

Ruby WHOIS Code:

class WHOIS


  def WHOISText
    socket =, 43)

    socket.write @domain + "\r\n"

    lines = ""

    while line = socket.gets
      lines += line






namespace EricBT
    public static class WHOIS
        public static string GetWHOISText(string domain)
            Globals.Log.InfoFormat("WHOIS.GetWHOISText: domain: {0}", domain);

            string serverResponse = null;

                string whoisServer = ConfigurationManager.AppSettings["WHOISServer"];

                using (TcpClient objTCPC = new TcpClient())
                    objTCPC.SendTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["WHOISSendTimeout"]);
                    objTCPC.ReceiveTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["WHOISReceiveTimeout"]);

                    objTCPC.Connect(whoisServer, 43);

                    string strDomain = string.Format("{0}\r\n", domain);

                    byte[] arrDomain = Encoding.ASCII.GetBytes(strDomain);

                    using (Stream objStream = objTCPC.GetStream())
                        objStream.Write(arrDomain, 0, strDomain.Length);

                        using (StreamReader objSr = new StreamReader(objTCPC.GetStream(), Encoding.ASCII))
                            serverResponse = objSr.ReadToEnd().Trim();

                            Globals.Log.InfoFormat("WHOIS.GetWHOISText: Response: {0}", serverResponse);
            catch (Exception ex)
                Globals.Log.ErrorFormat("WHOIS.GetWHOISText: Exception {0}", ex);

                serverResponse = string.Format("Error retrieving WHOIS information for domain '{0}'", domain);

            return serverResponse;
Keywords: Ruby on Rails, ASP.NET MVC, WHOIS, MySQL, MS SQL Server, Windows, Linux

Reader Comments

Comment on this Blog Post

Recent Posts

EBTCalc Users: A Desktop Version is Now Available!October 25, 2019
Python Script to Audit MediaMonkey TranscodingAugust 15, 2019
How to decompile Java code with JetBrains IntelliJ IDEA (2018.2.3, Windows 10)October 5, 2018
Java Programming Tip: SWT Photo Frame ProgramOctober 31, 2016
Vault 3 (Desktop) Version 1.63 ReleasedSeptember 9, 2016
"Compliance with Court Orders Act of 2016"April 9, 2016
Disable "Visual Voicemail" on Android / T-MobileJanuary 17, 2016