Modified lidgren to support IPv6 (code from https://github.com/lidgren/lidgren-network-gen3/pull/33). TODO: test

This commit is contained in:
Joonas Rikkonen
2018-11-24 20:14:59 +02:00
parent f3409f067d
commit f10ba10c63
6 changed files with 46 additions and 29 deletions
@@ -124,17 +124,18 @@ namespace Lidgren.Network
m_lastSocketBind = now;
if (m_socket == null)
m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
m_socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
if (reBind)
if (reBind)
m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, (int)1);
m_socket.ReceiveBufferSize = m_configuration.ReceiveBufferSize;
m_socket.SendBufferSize = m_configuration.SendBufferSize;
m_socket.Blocking = false;
m_socket.DualMode = true;
var ep = (EndPoint)new NetEndPoint(m_configuration.LocalAddress, reBind ? m_listenPort : m_configuration.Port);
m_socket.Bind(ep);
var ep = (EndPoint)new NetEndPoint(m_configuration.LocalAddress.MapToIPv6(), reBind ? m_listenPort : m_configuration.Port);
m_socket.Bind(ep);
try
{