示例#1
0
        public void StartLogging()
        {
            lock (this)
            {
                if (_server != null)
                {
                    return;
                }

                try
                {
                    // New server
                    _server = new SyslogServer(SyslogServer.DefaultAddress, _port);

                    // Register for events
                    _server.SyslogMessageReceived += _eventDelegate;

                    // Start listening
                    _server.Connect();
                }
                catch (Exception)
                {
                    if (_server != null)
                    {
                        _server.Close();
                        _server.SyslogMessageReceived -= _eventDelegate;
                        _server = null;
                    }

                    throw;
                }
            }
        }
		[Test] public void CreateServer()
		{
			SyslogServer srv = new SyslogServer();
			srv.Connect();
			Assert.IsTrue(srv.Connected, "Server connected");
			srv.Close();
		}
示例#3
0
        private void Connect()
        {
            if (_server != null)
            {
                return;
            }

            try
            {
                IPAddress ip = _specificIP;
                if (ip == null)
                {
                    ip = SyslogServer.DefaultAddress;
                }
                _server = new SyslogServer(ip, _port);
                _server.SyslogMessageReceived += new
                                                 SyslogServer.SyslogMessageDelegate(OnSyslogMessage);
                _server.Connect();
            }
            catch (Exception)
            {
                if (_server != null)
                {
                    _server.Close();
                    _server = null;
                }
                throw;
            }
        }
示例#4
0
        [Test] public void CreateServer()
        {
            SyslogServer srv = new SyslogServer();

            srv.Connect();
            Assert.IsTrue(srv.Connected, "Server connected");
            srv.Close();
        }