Exemple #1
0
        static void Main(string[] args)
        {
            //Test ntp
            NtpRequest ntpRequest = null;

            ntpRequest = NtpRequest.Create("pool.ntp.org", ntpPacket =>
            {
                ntpRequest.Close();
                if (ntpPacket != null)
                {
                    Console.WriteLine("[MAIN] NTP time test offset: " + ntpPacket.CorrectionOffset);
                }
                else
                {
                    Console.WriteLine("[MAIN] NTP time error");
                }
            });
            ntpRequest.Send();

            //new EchoMessagesTest().Run();
            //new HolePunchServerTest().Run();
            //new BroadcastTest().Run();
            //new BenchmarkTest.TestHost().Run();
            //new SerializerBenchmark().Run();
            new SpeedBench().Run();
            //new PacketProcessorExample().Run();
        }
Exemple #2
0
        private void RequestNtpService(string ntpService)
        {
            Console.WriteLine($"Request time from \"{ntpService}\" service");
#if NETSTANDARD || NETCOREAPP
            var result = NtpRequest.RequestAsync(ntpService).GetAwaiter().GetResult();
            if (result != null)
            {
                Console.WriteLine("[MAIN] NTP time test offset: " + result.CorrectionOffset);
            }
            else
            {
                Console.WriteLine("[MAIN] NTP time error");
            }
#else
            var ntpComplete = false;
            //Test ntp
            NtpRequest ntpRequest = null;
            ntpRequest = NtpRequest.Create(ntpService, ntpPacket =>
            {
                ntpRequest.Close();
                if (ntpPacket != null)
                {
                    Console.WriteLine("[MAIN] NTP time test offset: " + ntpPacket.CorrectionOffset);
                }
                else
                {
                    Console.WriteLine("[MAIN] NTP time error");
                }
                ntpComplete = true;
            });
            ntpRequest.Send();
            while (!ntpComplete)
            {
                Thread.Yield();
            }
#endif
        }