public void ConnectNTP(String ip, int port) { NTPClient client; try { client = new NTPClient(ip, port); client.Connect(false); } catch (Exception e) { Console.WriteLine("ERROR: {0}", e.Message); } }
public static int Main(string[] args) { Console.WriteLine("Time Synchronizer (C)2001 Valer BOCAN <*****@*****.**>"); Console.WriteLine("This program implements the Simple Network Time Protocol (see RFC 2030)\r\n"); Console.WriteLine("Connecting to: {0}\r\n", TimeServer); NTPClient client; try { client = new NTPClient(TimeServer); client.Connect(true); } catch (Exception e) { Console.WriteLine("ERROR: {0}", e.Message); return(-1); } Console.Write(client.ToString()); return(0); }
private void StartNTP(object s, EventArgs e) { TcpClient t; if ( m_dicCurrentConnections.ContainsKey( Thread.CurrentThread.ManagedThreadId) ) { m_dicCurrentConnections.TryGetValue(Thread.CurrentThread.ManagedThreadId,out t); string ip = t.Client.RemoteEndPoint.ToString().Split(":".ToCharArray()[0])[0]; NTPClient ntpClient = new NTPClient(ip, AirPlayHandler.NTP_PORT); ntpClient.Connect(false); } }