Results 1 to 5 of 5

Thread: How do you choose the fastest server from a DNS?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2003
    Location
    Eden Prairie Minnesota
    Posts
    301

    How do you choose the fastest server from a DNS?

    VB Code:
    1. Public Class SocketMaster
    2.  
    3.     Public Event OnConnect()
    4.     Public Event OnDisconnect()
    5.     Public Event OnError(ByVal Err As SocketException)
    6.  
    7.     Private Socket As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
    8.  
    9.     Public Sub Connect(ByVal server As String, ByVal port As Integer)
    10.         Dim hostEntry As IPHostEntry = Nothing
    11.         Dim address As IPAddress
    12.         Try
    13.             hostEntry = Dns.Resolve(server)
    14.             For Each address In hostEntry.AddressList
    15.                 Dim endPoint As New IPEndPoint(address, port)
    16.                 Socket = New Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
    17.                 Try
    18.                     Socket.Connect(endPoint)
    19.                     If Socket.Connected = True Then
    20.                         RaiseEvent OnConnect()
    21.                         Exit For
    22.                     End If
    23.                 Catch Err As SocketException
    24.                     RaiseEvent OnError(Err)
    25.                 End Try
    26.             Next address
    27.         Catch Err As SocketException
    28.             RaiseEvent OnError(Err)
    29.         End Try
    30.     End Sub
    31.  
    32.     Public Sub Disconnect()
    33.         Try
    34.             Socket.Close()
    35.             RaiseEvent OnDisconnect()
    36.         Catch Err As SocketException
    37.             RaiseEvent OnError(Err)
    38.         End Try
    39.     End Sub
    40.  
    41. End Class

    This is my socket class

    When you DNS like www.google.com and it gives you a list of address's, i want to ping each one to find the fastest, however i am unsure of how to do this.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2003
    Location
    Eden Prairie Minnesota
    Posts
    301

    Re: How do you choose the fastest server from a DNS?

    Does anyone know how to ping a server?

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: How do you choose the fastest server from a DNS?


  4. #4
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: How do you choose the fastest server from a DNS?

    "The dark side clouds everything. Impossible to see the future is."

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2003
    Location
    Eden Prairie Minnesota
    Posts
    301

    Re: How do you choose the fastest server from a DNS?

    The C# Examples, one didn't work

    The other wasn't exactly what i wanted

    The VB link was a little confusing, why was it VB6 Code?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width