string newServerIp = m_ip;
AddressFamily addressFamily = AddressFamily.InterNetwork;
//对IPV6进行支持
#if UNITY_IOS && !UNITY_EDITOR
if (GameManager.Instance != null && GameManager.Instance.appleInterFace != null)
{
GameManager.Instance.appleInterFace.GetIPv6Type(m_ip, m_port, out newServerIp, out addressFamily);
}
#endif
tcpClient = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
IPAddress ip = IPAddress.Parse(newServerIp);
IPEndPoint remoteEP = new IPEndPoint(ip, System.Int32.Parse(m_port));
//绑定异步连接回调函数
tcpClient.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), tcpClient);
源码下载地址
https://download.youkuaiyun.com/download/springhao123/10636696
博客展示了一段代码,实现了Socket的异步连接,同时对IPV6进行支持。代码中定义了新的服务器IP和地址族,在特定条件下调用接口获取IPv6类型,创建Socket并解析IP地址,最后绑定异步连接回调函数。还给出了源码下载地址。
1294

被折叠的 条评论
为什么被折叠?



