/// <summary> /// Creates a new UdpConnectionListener for the given <see cref="IPAddress"/>, port and <see cref="IPMode"/>. /// </summary> /// <param name="endPoint">The endpoint to listen on.</param> public UdpConnectionListener(IPEndPoint endPoint, ObjectPool <MessageReader> readerPool, IPMode ipMode = IPMode.IPv4) { this.EndPoint = endPoint; this.IPMode = ipMode; _readerPool = readerPool; _socket = new UdpClient(endPoint); try { _socket.DontFragment = false; } catch (SocketException) { } _reliablePacketTimer = new Timer(ManageReliablePackets, null, 100, Timeout.Infinite); _allConnections = new ConcurrentDictionary <EndPoint, UdpServerConnection>(); _stoppingCts = new CancellationTokenSource(); _stoppingCts.Token.Register(() => { _socket.Dispose(); }); _connectionRateLimit = new UdpConnectionRateLimit(); }