コード例 #1
0
 public void BeginConnect(string address, int port, SslCertBundleInfo bundleInfo, BeginConnectDelegate connectDelegate)
 {
     try
     {
         string str;
         string str2;
         try
         {
             UriUtils.GetHostAddress(address, out str);
         }
         catch (Exception exception)
         {
             s_log.LogError("Exception within GetHostAddress: " + exception.Message);
             return;
         }
         this.m_address = address;
         if (UriUtils.GetHostAddressAsIp(address, out str2))
         {
             this.m_address = "::ffff:" + address;
         }
         this.m_resolvedAddress = "::ffff:" + str;
         object[] args = new object[] { str, port };
         s_log.LogDebug("Connecting to {0}:{1}", args);
         IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(str), port);
         this.m_beginConnectDelegate = connectDelegate;
         this.m_bundleInfo           = bundleInfo;
         this.m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         this.m_socket.BeginConnect(remoteEP, new AsyncCallback(this.ConnectCallback), address);
     }
     catch (Exception exception2)
     {
         object[] objArray2 = new object[] { exception2 };
         s_log.LogWarning("Exception while trying to call BeginConnect. {0}", objArray2);
         this.ExecuteBeginConnectDelegate(true);
     }
 }