تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] اريد شرح الكود او توضيح الفكرة العامة له
#1
السلام عليكم ورحمة الله وبركاته
اريد حد يشرحلى الكود ده او يوضح الفكرة العامة له


كود :
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox(GetFastestNISTDate().ToLocalTime)
    End Sub

    Public Function GetFastestNISTDate() As DateTime
        Dim result = DateTime.MinValue
        ' Initialize the list of NIST time servers
        ' http://tf.nist.gov/tf-cgi/servers.cgi
        Dim servers As String() = New String() _
        {"nist1-ny.ustiming.org", "nist1-nj.ustiming.org", "nist1-pa.ustiming.org", "time-a.nist.gov", "time-b.nist.gov", "nist1.aol-va.symmetricom.com", _
         "nist1.columbiacountyga.gov", "nist1-chi.ustiming.org", "nist.expertsmi.com", "nist.netservicesgroup.com"}

        ' Try 5 servers in random order to spread the load
        Dim rnd As New Random()
        For Each server As String In servers.OrderBy(Function(s) rnd.NextDouble()).Take(5)
            Try
                ' Connect to the server (at port 13) and get the response
                Dim serverResponse As String = String.Empty
                Using reader = New IO.StreamReader(New System.Net.Sockets.TcpClient(server, 13).GetStream())
                    serverResponse = reader.ReadToEnd()
                End Using

                ' If a response was received
                If Not String.IsNullOrEmpty(serverResponse) Then
                    ' Split the response string ("55596 11-02-14 13:54:11 00 0 0 478.1 UTC(NIST) *")
                    Dim tokens As String() = serverResponse.Split(" "c)

                    ' Check the number of tokens
                    If tokens.Length >= 6 Then
                        ' Check the health status
                        Dim health As String = tokens(5)
                        If health = "0" Then
                            ' Get date and time parts from the server response
                            Dim dateParts As String() = tokens(1).Split("-"c)
                            Dim timeParts As String() = tokens(2).Split(":"c)

                            ' Create a DateTime instance
                            Dim utcDateTime As New DateTime(Convert.ToInt32(dateParts(0)) + 2000, Convert.ToInt32(dateParts(1)), Convert.ToInt32(dateParts(2)), Convert.ToInt32(timeParts(0)), Convert.ToInt32(timeParts(1)), Convert.ToInt32(timeParts(2)))

                            ' Convert received (UTC) DateTime value to the local timezone
                            result = utcDateTime '.ToLocalTime()

                            ' Response successfully received; exit the loop

                            Return result
                        End If

                    End If

                End If
                ' Ignore exception and try the next server
            Catch
            End Try
        Next
        Return result
    End Function

End Class
الرد }}}
تم الشكر بواسطة: hoob computer


الردود في هذا الموضوع
اريد شرح الكود او توضيح الفكرة العامة له - بواسطة ali.alfoly - 17-10-13, 05:48 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
Information ما هو الخطاء في الكود ProgressBar1 Mostafa201255411 1 200 26-11-25, 08:19 PM
آخر رد: asmarsou
  [VB.NET] مساعدة تعديل على الكود ZEEN4ZEEN 2 218 08-10-25, 02:20 PM
آخر رد: salamandal
Rainbow [كود] تصحيح الخطاء في الكود محمد مسافر 2 1,055 28-08-25, 09:13 AM
آخر رد: محمد مسافر
Rainbow [كود] تصحيح الخطاء في الكود محمد مسافر 0 848 27-08-25, 04:05 PM
آخر رد: محمد مسافر
  ما هو الخطأ فى هذا الكود خالد كامل1 10 1,197 28-05-25, 09:16 PM
آخر رد: خالد كامل1
  ارجو تعديل الكود بواستطة الاجراء المخزن new_programer 3 683 03-04-25, 02:44 PM
آخر رد: princelovelorn
  مساعدة في تحويل الكود من فيجوال بسيك 6 الى فيجوال دوت نت سيد أحمد 5 829 23-03-25, 10:54 PM
آخر رد: سيد أحمد
  [سؤال] اريد طباعة تقرير ريبورت فيو مباشرة فور عرض التقرير mh66 1 565 22-03-25, 09:59 AM
آخر رد: mh66
  اريد كود لو سمحتم خالد كامل1 10 1,233 15-02-25, 02:15 PM
آخر رد: خالد كامل1
  ارجو تعديل الكود جلب البيانات عن طريق اجراء مخزن - مرفق مثال new_programer 0 626 05-02-25, 01:51 AM
آخر رد: new_programer

التنقل السريع :


يقوم بقرائة الموضوع: