public static void Main(string[] args) { var settings = Settings.Default; IPAddress address; if (!IPAddress.TryParse(settings.ListenIPAddress, out address)) { address = IPAddress.Any; } var listener = new Listener(address, settings.ListenPort, settings.BufferFlushFrequency); listener.MessageReceived += MessageReceived; var consoleServer = new SysLogServer(listener); if (consoleServer.Start()) { Console.WriteLine("Listener Started. Press any key to stop listener"); Console.WriteLine("Console server started."); Console.ReadLine(); } consoleServer.Stop(); }
protected override void OnStart(string[] args) { if (_listener == null) { var settings = Settings.Default; IPAddress address; if (!IPAddress.TryParse(settings.ListenIPAddress, out address)) { address = IPAddress.Any; } _listener = new Listener(address, settings.ListenPort, settings.BufferFlushFrequency); } if (_sysLogServer == null) { _sysLogServer = new SysLogServer(_listener); } _sysLogServer.Start(); }
/// <summary> /// Creates an instance of the Listener if one does not already exist. /// </summary> /// <param name="listenIPAddress">A valid IPv4 address.</param> /// <param name="listenPort">A valid port value from 1 to 65535.</param> /// <returns>Returns a Listner object.</returns> public static Listener CreateInstance(string listenIPAddress, int listenPort, int logFlushFrequency) { if (_instance == null) { _instance = new Listener(listenIPAddress, listenPort, logFlushFrequency); } return _instance; }