locked
Connecting to Local computer RRS feed

  • Question

  • Hey there, i've got some problems while connecting to my local computer...
    The problem is, that when i connect to my Host name / Computer name, it takes arround 6 secs to connect..

    TcpClient

    new TcpClient("127.0.0.1", 1990);       FAST
    new TcpClient("10.0.0.14", 1990);       FAST
    new TcpClient("localhost", 1990);       1-2 seconds
    new TcpClient("PEmich", 1990);          4-6 seconds


    I hope that somebody know how this problem can be solved, or is there a way to get the IP from somebody´s ComputerName?

    Paul
    Thursday, November 15, 2007 8:58 PM

Answers

  • Accessing a computer by name needs to have the name resolved with DNS, even "localhost".  This takes a bit more time that if you simply use the numeric IP address.

     

    Thursday, November 15, 2007 9:04 PM
  • You could use System.Net.Dns.GetHostAddresses to have the lookup performed before the allocation of your TcpClient objects.  I doubt it would be any faster.

    Thursday, November 15, 2007 9:33 PM

All replies

  • Accessing a computer by name needs to have the name resolved with DNS, even "localhost".  This takes a bit more time that if you simply use the numeric IP address.

     

    Thursday, November 15, 2007 9:04 PM
  • Is there a fast way to detect the IP of the hostname? Or should i just use the way that im trying now?
    Thursday, November 15, 2007 9:13 PM
  • You could use System.Net.Dns.GetHostAddresses to have the lookup performed before the allocation of your TcpClient objects.  I doubt it would be any faster.

    Thursday, November 15, 2007 9:33 PM