Im trying to read ntp through streamreader and i find it difficult when fetching time from ph.pool.ntp.org and it gives me an outofboundsexception when i try to run it on timer
heres my code
 Public Function GetNISTTime(ByVal host As String) As DateTime
    Dim timeStr As String = ""
    Try
        Dim reader As New StreamReader(New TcpClient(host, 13).GetStream)
        timeStr = reader.ReadToEnd()
        Console.WriteLine(timeStr.ToString)
        reader.Close()
    Catch ex As SocketException
        Label1.Text = ex.Message
    Catch ex As Exception
        Label1.Text = ex.Message
    End Try
    Dim jd As Integer = Integer.Parse(timeStr.Substring(1, 5))
    Dim yr As Integer = Integer.Parse(timeStr.Substring(7, 2))
    Dim mo As Integer = Integer.Parse(timeStr.Substring(10, 2))
    Dim dy As Integer = Integer.Parse(timeStr.Substring(13, 2))
    Dim hr As Integer = Integer.Parse(timeStr.Substring(16, 2))
    Dim mm As Integer = Integer.Parse(timeStr.Substring(19, 2))
    Dim sc As Integer = Integer.Parse(timeStr.Substring(22, 2))
    Dim Temp As Integer = CInt(AscW(timeStr(7)))
    Return New DateTime(yr + 2000, mo, dy, hr, mm, sc)
End Function
and the host name are loaded in the timer
Label1.Text = GetNISTTime("ph.pool.ntp.org ").ToString
and it is start by a timer.start() in form load.
 
     
     
     
    