private void DisplayConnectionSuccess() { if (_connected) { Action helpAction = () => { ConnectionSuccessFull(); ConnectionHelp.Visible = false; AutoDownload.Visible = true; FileExplorer.Visible = true; }; ConnectionHelp.Invoke(helpAction); } else { _failCount++; Action tileAction = ConnectionFailed; ConnectionTile.Invoke(tileAction); if (_failCount > 1) { Action helpAction = () => ConnectionHelp.Visible = true; ConnectionHelp.Invoke(helpAction); } RetryConnection(); } }
public SocketClient(string ip, int port) { //targetIpString = ip; targetPort = port; #region ipv6 String newServerIp = ""; getIPType(ip, port.ToString(), out newServerIp, out newAddressFamily); // 这里newServerIp已经是IPv6类型的IP地址了 if (!string.IsNullOrEmpty(newServerIp)) { ip = newServerIp; } //socketClient = new Socket(newAddressFamily, SocketType.Stream, ProtocolType.Tcp); Debug.Log("Socket AddressFamily :" + newAddressFamily.ToString() + " ServerIp:" + ip + " newServerIp:" + newServerIp); #endregion if (ip.ToLower() == "local" || ip.ToLower() == "localhost") { TargetIPAddress = ConnectionHelp.GetMyIP(); } else { //TargetIPAddress = Dns.GetHostAddresses(ip).First(p => p.AddressFamily == AddressFamily.InterNetwork); TargetIPAddress = Dns.GetHostAddresses(ip).First(p => p.AddressFamily == newAddressFamily); Debug.Log("TargetIPAddress :" + TargetIPAddress); // 这里的TargetIPAddress已经是IPv6类型的IP地址了 } }