Menu

#5 Take a hostname for a server to connect to

open
nobody
8
2006-01-25
2006-01-25
Anonymous
No

Right now we have to give an IP address to connect to.
It would be very nice if we could simply use hostnames
and fully qualified domain names.

Discussion

  • Tim Gebhardt

    Tim Gebhardt - 2006-01-25
    • priority: 5 --> 8
     
  • CarpDeus

    CarpDeus - 2007-06-25

    Logged In: YES
    user_id=1827507
    Originator: NO

    Easy enough to do. Modify SockIOPool's SetServer(ArrayList servers) with the code below. While .NET 1's Dns.Resolve will work with 2.0, I'm using 2.0's recommended GetHostEntry.

    I still need to do some testing to see what kind of throughput this gets. MS says I should be able to just use the DNS resolution without loss of performance even on IP addresses but I would like to test this out before I drop the initial check for an IP address

    public void SetServers(ArrayList servers)
    {
    for (int i = 0; i < servers.Count; i++)
    {
    try
    {
    Convert.ToInt64(servers[i].ToString().Replace(".", "").Replace(":", ""));
    }
    catch
    {
    string PortNumber = servers[i].ToString().Substring(servers[i].ToString().IndexOf(":"));
    // .NET 1
    //ResolvedServers.Append(Dns.Resolve(servers[i].ToString().Substring(0, servers[i].ToString().LastIndexOf(":"))).AddressList[0].ToString());
    servers[i] = Dns.GetHostEntry(servers[i].ToString().Substring(0, servers[i].ToString().LastIndexOf(":"))).AddressList[0].ToString() + PortNumber;
    }
    }
    _servers = servers;
    }

     

Log in to post a comment.