private void InnerHandleSocketConnectFailed()
 {
     if (this.CanConnectAlternateIp)
     {
         try
         {
             this.ConnectAlternateIp();
         }
         catch
         {
             this.State = AbstractTcpClient.SocketState.Failed;
         }
     }
     else
     {
         this.State = AbstractTcpClient.SocketState.Failed;
     }
 }
 private void OnConnectHost(IAsyncResult result)
 {
     try
     {
         Socket socket = result.AsyncState as Socket;
         if (socket.Connected)
         {
             this._headerBuffer   = new byte[4];
             this._bodyLength     = 0;
             this._readBodyLength = 0;
             this.State           = AbstractTcpClient.SocketState.Success;
         }
         else
         {
             this.InnerHandleSocketConnectFailed();
         }
     }
     catch
     {
         this.InnerHandleSocketConnectFailed();
     }
 }
 public void Connect(string host, int port, Action callback)
 {
     if (this.State == AbstractTcpClient.SocketState.Connecting)
     {
         return;
     }
     this.Close();
     this._host                  = host;
     this._port                  = port;
     this._callback              = callback;
     this._sendQueue             = new Queue <Dictionary <string, object> >();
     this.State                  = AbstractTcpClient.SocketState.Connecting;
     this._canConnectAlternateIp = true;
     Logger.LogInfo(string.Concat(new object[]
     {
         "开始连接Socket : ",
         this._host,
         ":",
         this._port
     }));
     this.SafeStartCoroutine(ref this._waitCoroutine, this.WaitSocketConnect());
     Dns.BeginGetHostAddresses(host, new AsyncCallback(this.OnGetHostAddress), host);
 }