> I've tested this. I provided IP, that definetelly isn't active in my
> netwrok and isn't on my DNS. I got result without problems. I can send
> you video. :)

Alright. Here is a program that I ran on my computer:

    public static void Main(string[] args)
    {
        string address = args[0];
        Console.WriteLine("Testing: {0}", address);

        IPHostEntry hostent = Dns.GetHostEntry(address);
        Console.WriteLine("Hostname: {0}", hostent.HostName);
        foreach(string alias in hostent.Aliases)
        {
            Console.WriteLine("Alias: {0}", alias);
        }
        foreach(IPAddress addr in hostent.AddressList)
        {
            Console.WriteLine("Address: {0}", addr);
        }
    }

Here is the output for two different addresses:

D:\Projects\TestProject\bin\Debug>test 10.0.0.33
Testing: 10.0.0.33
Hostname: xxxxxx
Address: fe80::69eb:837:6a0:5c66%8
Address: fe80::5efe:10.0.0.33%11
Address: 10.0.0.33

D:\Projects\TestProject\bin\Debug>test 123.123.123.123
Testing: 123.123.123.123
Hostname: 123.123.123.123
Address: 123.123.123.123

The first address is my local IP address. Notice how it returned the IPv6
addresses *before* the IPv4 (this is Windows Vista). The second address is
one that does not exist on my network. Not visible here, of course, is the
fact that this address took about 6 seconds to "resolve" whereas the first
one was practically instant.

Your network may be different, but clearly not all networks are the same as
yours.

Remember, all I'm trying to say here is that you should replace the line:

IPAddress addr = Dns.GetHostEntry(hostname).AddressList[0];

With the following:

IPAddress addr;
if (!IPAddress.Parse(hostname, out addr))
{
  addr = Dns.GetHostEntry(hostname).AddressList[0];
}

It's not a big change and it's only useful in certain circumstances, but it
*is* a better solution.

Dean.




-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to