コード例 #1
0
        /// <summary>
        /// Implements ILogCollector.SubmitMessage
        /// </summary>
        public void SubmitMessage(SyslogMessage message)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            byte[] dgram = message.ToByteArray();

            _listlock.AcquireReaderLock(DEFAULT_JOIN_TIMEOUT);
            try
            {
                Dictionary <string, UdpClientExpire> .Enumerator enumeratore = _clients.GetEnumerator();

                while (enumeratore.MoveNext())
                {
                    UdpClient client = enumeratore.Current.Value.Client;
                    if (client != null)
                    {
                        try
                        {
                            client.BeginSend(dgram, dgram.Length, null, null);
                        }
                        catch (SocketException)
                        {
                            //What to do????
                            //For now, ignore and drop message
                        }
                    }
                }
            }
            finally
            {
                _listlock.ReleaseReaderLock();
            }
        }