Network: Add support for dual-stack sockets

This commit is contained in:
Lynix
2018-04-01 20:48:50 +02:00
parent 600bfc3ee6
commit 715729fc02
10 changed files with 75 additions and 11 deletions

View File

@@ -156,6 +156,7 @@ namespace Nz
UInt64 m_totalReceivedData;
bool m_allowsIncomingConnections;
bool m_continueSending;
bool m_isUsingDualStack;
bool m_isSimulationEnabled;
bool m_recalculateBandwidthLimits;

View File

@@ -9,6 +9,7 @@ namespace Nz
{
inline ENetHost::ENetHost() :
m_packetPool(sizeof(ENetPacket)),
m_isUsingDualStack(false),
m_isSimulationEnabled(false)
{
}
@@ -20,21 +21,22 @@ namespace Nz
inline bool ENetHost::Create(NetProtocol protocol, UInt16 port, std::size_t peerCount, std::size_t channelCount)
{
NazaraAssert(protocol != NetProtocol_Any, "Any protocol not supported for Listen"); //< TODO
NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol");
IpAddress any;
switch (protocol)
{
case NetProtocol_Any:
case NetProtocol_Unknown:
NazaraInternalError("Invalid protocol Any at this point");
NazaraInternalError("Invalid protocol");
return false;
case NetProtocol_IPv4:
any = IpAddress::AnyIpV4;
break;
case NetProtocol_Any:
m_isUsingDualStack = true;
// fallthrough
case NetProtocol_IPv6:
any = IpAddress::AnyIpV6;
break;

View File

@@ -51,15 +51,15 @@ namespace Nz
IpAddress any;
switch (m_protocol)
{
case NetProtocol_Any:
case NetProtocol_Unknown:
NazaraInternalError("Invalid protocol Any at this point");
NazaraInternalError("Invalid protocol");
return SocketState_NotConnected;
case NetProtocol_IPv4:
any = IpAddress::AnyIpV4;
break;
case NetProtocol_Any:
case NetProtocol_IPv6:
any = IpAddress::AnyIpV6;
break;