1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 07:06:30 +09:00

Can configure to be dual-mode, or plain IPv4/6

This commit is contained in:
CallumDev
2019-06-10 02:28:38 +09:30
parent 1a2301ddbc
commit 85ad100f89
4 changed files with 27 additions and 8 deletions

View File

@@ -123,7 +123,7 @@ namespace Lidgren.Network
mutex.WaitOne();
if (m_socket == null)
m_socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
m_socket = new Socket(m_configuration.LocalAddress.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
if (reBind)
m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, (int)1);
@@ -131,7 +131,9 @@ namespace Lidgren.Network
m_socket.ReceiveBufferSize = m_configuration.ReceiveBufferSize;
m_socket.SendBufferSize = m_configuration.SendBufferSize;
m_socket.Blocking = false;
m_socket.DualMode = true;
if(m_configuration.DualStack && m_configuration.LocalAddress.AddressFamily == AddressFamily.InterNetworkV6)
m_socket.DualMode = true;
var ep = (EndPoint)new NetEndPoint(m_configuration.LocalAddress.MapToIPv6(), reBind ? m_listenPort : m_configuration.Port);
m_socket.Bind(ep);