Click here to Skip to main content
15,895,084 members
Articles / Programming Languages / C#

STUN Client

Rate me:
Please Sign up or sign in to vote.
4.83/5 (36 votes)
20 Apr 2007CPOL 329.2K   14.9K   85  
STUN client C# implementation with sample application
using System;

namespace LumiSoft.Net.Dns.Client
{
	/// <summary>
	/// MX record class.
	/// </summary>
	[Serializable]
	public class MX_Record : DnsRecordBase,IComparable
	{
		private int    m_Preference = 0;
		private string m_Host       = "";

		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="preference">MX record preference.</param>
		/// <param name="host">Mail host dns name.</param>
		/// <param name="ttl">TTL value.</param>
		public MX_Record(int preference,string host,int ttl) : base(QTYPE.MX,ttl)
		{
			m_Preference = preference;
			m_Host       = host;
        }


        #region IComparable Implementation

        /// <summary>
        /// Compares the current instance with another object of the same type. 
        /// </summary>
        /// <param name="obj">An object to compare with this instance. </param>
        /// <returns>Returns 0 if two objects are equal, returns negative value if this object is less,
        /// returns positive value if this object is grater.</returns>
        public int CompareTo(object obj)
        {
            if(obj == null){
                throw new ArgumentNullException("obj");
            }
            if(!(obj is MX_Record)){
                throw new ArgumentException("Argument obj is not MX_Record !");
            }

            MX_Record mx = (MX_Record)obj;
            if(this.Preference > mx.Preference){
                return 1;
            }
            else if(this.Preference < mx.Preference){
                return -1;
            }
            else{
                return 0;
            }
        }

        #endregion


        #region Properties Implementation

        /// <summary>
		/// Gets MX record preference. The lower number is the higher priority server.
		/// </summary>
		public int Preference
		{
			get{ return m_Preference; }
		}

		/// <summary>
		/// Gets mail host dns name.
		/// </summary>
		public string Host
		{
			get{ return m_Host; }
		}

		#endregion

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Estonia Estonia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions