TNet had issue with parsing IPv6 addresses in the past (see:
http://www.tasharen.com/forum/index.php?topic=13794). However, even with the parsing fixed - in TNet2 - Sockets are created with AddressFamily.InterNetwork (see TcpProtocol::ConnectToTcpEndPoint()), which, as far as I can tell, only supports IPv4. In .NET 4.5 Sockets support dual mode, but I don't think Unity has caught up to that yet.
If I change AddressFamily.InterNetwork to tcpEndPoint.AddressFamily, will this introduce incompatibilities? Has IPv6 support been more thoroughly planned out in TNet3?
I know this is something I could test myself, but I thought I might check here before potentially breaking the whole game
edit: Here's all the changes I've made in TNet2. I think this should solve IPv6 problems when using TCP. Not sure though. The Lobby code (client and server) should be fine already.
TNManager::Connect (string address) [full function]:
string parsedAddress = address;
string[] split
= address
.Split(new char[] { ':' }); int port = 5127;
if (split.Length == 2)
{
int.TryParse(split[1], out port);
}
else if (split.Length == 9)
{
parsedAddress = address.Substring(0, address.Length - split[8].Length - 1);
int.TryParse(split[8], out port);
}
Connect(parsedAddress, port);
TcpProtocol::ConnectToTcpEndPoint():
Change:
mSocket
= new Socket
(AddressFamily
.InterNetwork, SocketType
.Stream, ProtocolType
.Tcp);
To:
mSocket
= new Socket
(tcpEndPoint
.AddressFamily, SocketType
.Stream, ProtocolType
.Tcp);if (tcpEndPoint.AddressFamily == AddressFamily.InterNetworkV6)
mSocket.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27, 0);
TNTools.cs -
Tools::ResolveExternalIP (string url):
Change:
string[] split1 = text.Split(':');
if (split1.Length >= 2)
{
string[] split2 = split1[1].Trim().Split('<');
mExternalAddress = ResolveAddress(split2[0]);
}
else mExternalAddress = ResolveAddress(text);
To:
mExternalAddress = ResolveAddress(text);
Tools::IsValidAddress (IPAddress address):
Change:
if (address.AddressFamily != AddressFamily.InterNetwork) return false;
To:
if ((address.AddressFamily != AddressFamily.InterNetwork) && (address.AddressFamily != AddressFamily.InterNetworkV6)) return false;
Tools::ResolveEndPoint (string address):
Change:
if (split.Length > 1)
{
address = split[0];
int.TryParse(split[1], out port);
}
To:
if (split.Length == 2)
{
address = split[0];
int.TryParse(split[1], out port);
}
else if (split.Length == 9)
{
address = address.Substring(0, address.Length - split[8].Length - 1);
int.TryParse(split[8], out port);
}
Sorry for ugly formatting. I tried