lamp

September 2008 - Posts

Reverse DNS lookup with Timeout in c#
09 September 08 06:50 AM | Frederick.Chapleau | 6 comment(s)

Everybody can use the method GetHostEntry  of the DNS class inside .NET 2.0. But as far as I know, it does timeout only after 5 seconds, that is absolutely too much in an application context where you want to resolve multiple IP addresses.

Also, you might want to return the requested IP address instead of an exception.

That is why I build this little widget that is using asynchronous call to timeout the GetHostEntry method, and return the IP address in the case of a timeout.

private delegate IPHostEntry GetHostEntryHandler(string ip);

public string GetReverseDNS(string ip, int timeout)
{
    try
    {
        GetHostEntryHandler callback = new GetHostEntryHandler(Dns.GetHostEntry);
        IAsyncResult result = callback.BeginInvoke(ip,null,null);
        if (result.AsyncWaitHandle.WaitOne(timeout, false))
        {
            return callback.EndInvoke(result).HostName;
        }
        else
        {
            return ip;
        }
    }
    catch (Exception)
    {
        return ip;
    }
}

-f.

Filed under:
Changing the name of a SQL 2005 Server
08 September 08 03:43 PM | Frederick.Chapleau | with no comments

A good article on MSDN

http://msdn.microsoft.com/en-us/library/ms143799.aspx

Greatly improved since SQL 2000...

-f.

Filed under:
Google Chrome : The Google Browser
03 September 08 12:02 PM | Frederick.Chapleau | with no comments

Finally it's available! The Google web browser!

Some stats of Google Chrome compared to IE7:

RAM Usage : 128meg + 60/tab (150 + 50meg for IE7)

Speed: Extremely fast (better than Firefox) ?

Thread: Exactly the same number of thread

UI: Really simple UI

Startup : Half a second (7 second for the same page in IE7)

http://www.google.com/chrome

-f.

Filed under: