ios piv6遭拒绝

最近ios上线一款网游,审核时因为不支持ipv6未被通过,解决方式:

private IPAddress[] taddress;

public Socket clientSocket;

public void ConnectToServer()
{

//测试用的网址

taddress = Dns.GetHostAddresses ("xxxx.com");

foreach (var info in taddress) {
Debug.Log (info);
}

if (taddress [0].AddressFamily == AddressFamily.InterNetworkV6) {
Debug.Log ("Connect IPV6");
clientSocket = new Socket (AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
} else {
Debug.Log ("Connect IPV4");
clientSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}
//跟服务器连接
try
{
clientSocket.Connect(taddress, ConstInfo.port);
}
catch (System.Exception e)
{
Debug.Log(e.Message);
return;
}

//客户端开启线程接收数据

try
{
if (thread != null)
{
thread.Abort();
Debug.Log("关闭上一次的线程");
}
}
catch
{

}


Debug.Log("开启线程");
Debug.Log("ConnectToServer");

clientSocket.SendTimeout = 1000;
thread = new Thread(ReceiveMessage);
thread.Start();
}

posted @ 2017-07-13 11:10  任雪松  阅读(381)  评论(0编辑  收藏  举报