版权声明:转发,使用请留言告知 https://blog.csdn.net/qq_37310110/article/details/81905629
做了一个产品,在ios审核上架的时候biej被拒了如下:
Guideline 2.1 - Performance - App Completeness
We discovered one or more bugs in your app when reviewed on iPhone running iOS 11.4.1 on Wi-Fi connected to an IPv6 network.
Specifically, when we tapped on the log in button, no further action took place.
意思是说应用在ipv6的环境下不能登录。
然后我们就要找解决方案了:
之前的scoket连接建立,AddressFamily.InterNetwork是ipv4的网络
/// <param name="port">端口号</param>
public void CreateConnection(string serverAddress, int port)
{
if (scoket != null && scoket.Connected)
{
return;
}
try
{
this.scoket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
this.scoket.NoDelay = true;
IPEndPoint end_point = new IPEndPoint(IPAddress.Parse(serverAddress), port);
this.scoket.BeginConnect(end_point, new AsyncCallback(this.Connected), this.scoket);
}
catch (Exception e)
{
Debuger.Log( e.Message);
}
}
我们需要检测当前网络环境类型并做兼容处理如下
/// <param name="port">端口号</param>
public void CreateConnection(string serverAddress, int port)
{
if (scoket != null && scoket.Connected)
{
return;
}
try
{
IPAddress[] address = Dns.GetHostAddresses(serverAddress);
if (address[0].AddressFamily == AddressFamily.InterNetworkV6)
{
Debug.Log("Connect InterNetworkV6");
scoket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
}
else
{
Debug.Log("Connect InterNetwork");
scoket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}
this.scoket.NoDelay = true;
IPEndPoint end_point = new IPEndPoint(IPAddress.Parse(serverAddress), port);
this.scoket.BeginConnect(end_point, new AsyncCallback(this.Connected), this.scoket);
}
catch (Exception e)
{
Debuger.Log( e.Message);
}
}
IPAddress[] address = Dns.GetHostAddresses(serverAddress);我们可以知道当前网络环境类型,然后创建对应连接的scoket