using System;
using System.Globalization;
using System.Net;

namespace StandardScene.TCP
{
    /// <summary>
    /// 与服务器的连接发生异常事件
    /// </summary>
    public class TcpServerExceptionOccurredEventArgs : EventArgs
    {
        public TcpServerExceptionOccurredEventArgs(IPAddress ipAddresses, int port, Exception innerException)
        {
            if (ipAddresses == null)
            {
                throw new ArgumentNullException("ipAddress");
            }
            this.Address = ipAddresses;
            this.Port = port;
            this.Exception = innerException;
        }

        public IPAddress Address { get; private set; }

        public int Port { get; private set; }

        public Exception Exception { get; private set; }

        public override string ToString()
        {
            return this.Address + ":" + this.Port.ToString(CultureInfo.InvariantCulture);
        }
    }
}