苹果过审ipv6问题
生活随笔
收集整理的這篇文章主要介紹了
苹果过审ipv6问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
蘋果過審有一項是必須通過ipv6網絡測試游戲,一開始的想法是實現兩套socket鏈接,服務器也實現ipv6,后來百度了其實很簡單,直接Dns.GetHostAddresses(string hostNameOrAddress)獲取鏈接地址,hostNameOrAddress傳域名地址,域名綁定服務器ip就好了,下面是完整代碼:
1 /// <summary> 2 /// 連接服務器 3 /// </summary> 4 void ConnectServer(string host, int port) { 5 TcpClient client = null; 6 7 //獲取遠端服務器ip地址 8 IPAddress[] address = Dns.GetHostAddresses(host); 9 if (address.Length == 0) 10 { 11 Debug.LogError("address.Length == 0"); 12 return; 13 } 14 15 //判斷當前網絡是否為ipv6建立不同鏈接 16 if (address[0].AddressFamily == AddressFamily.InterNetworkV6) 17 { 18 client = new TcpClient(AddressFamily.InterNetworkV6); 19 } 20 else 21 { 22 client = new TcpClient(AddressFamily.InterNetwork); 23 } 24 25 //建立鏈接 26 client.NoDelay = true; 27 try { 28 client.BeginConnect(address[0], port, new AsyncCallback(OnConnect), null); 29 } catch (Exception e) { 30 Close(); Debug.LogError(e.Message); 31 } 32 } View Code?
?
轉載于:https://www.cnblogs.com/ChengShuKaiShi/p/7750482.html
總結
以上是生活随笔為你收集整理的苹果过审ipv6问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【BZOJ4231】回忆树 离线+fai
- 下一篇: pyplot绘图标题错误处理