<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using NMaier.SimpleDlna.Utilities;
using Threading = System.Threading;
using Timers = System.Timers;

namespace NMaier.SimpleDlna.Server.Ssdp
{
  internal sealed class SsdpHandler : Logging, IDisposable
  {
    private readonly UdpClient client = new UdpClient();
    private readonly Threading.AutoResetEvent datagramPosted = new Threading.AutoResetEvent(false);
    private const int DATAGRAMS_PER_MESSAGE = 3;
    private readonly Dictionary<Guid, List<UpnpDevice>> devices = new Dictionary<Guid, List<UpnpDevice>>();
    private readonly Queue<Datagram> messageQueue = new Queue<Datagram>();
    private readonly Timers.Timer notificationTimer = new Timers.Timer(60000);
    private readonly Timers.Timer queueTimer = new Timers.Timer(1000);
    private static readonly Random random = new Random();
    private bool running = true;
    const string SSDP_ADDR = "172.16.31.10";
    private static readonly IPEndPoint SSDP_ENDP = new IPEndPoint(IPAddress.Parse(SSDP_ADDR), SSDP_PORT);
    private static readonly IPAddress SSDP_IP = IPAddress.Parse(SSDP_ADDR);
    const int SSDP_PORT = 1900;



    public SsdpHandler()
    {
      notificationTimer.Elapsed += Tick;
      notificationTimer.Enabled = true;

      queueTimer.Elapsed += ProcessQueue;

      client.Client.UseOnlyOverlappedIO = true;
      client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
      client.ExclusiveAddressUse = false;
      client.Client.Bind(new IPEndPoint(IPAddress.Any, SSDP_PORT));<commit_msg>SSDP: Send only 2 datagrams per message<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using NMaier.SimpleDlna.Utilities;
using Threading = System.Threading;
using Timers = System.Timers;

namespace NMaier.SimpleDlna.Server.Ssdp
{
  internal sealed class SsdpHandler : Logging, IDisposable
  {
    private readonly UdpClient client = new UdpClient();
    private readonly Threading.AutoResetEvent datagramPosted = new Threading.AutoResetEvent(false);
    private const int DATAGRAMS_PER_MESSAGE = 2;
    private readonly Dictionary<Guid, List<UpnpDevice>> devices = new Dictionary<Guid, List<UpnpDevice>>();
    private readonly Queue<Datagram> messageQueue = new Queue<Datagram>();
    private readonly Timers.Timer notificationTimer = new Timers.Timer(60000);
    private readonly Timers.Timer queueTimer = new Timers.Timer(1000);
    private static readonly Random random = new Random();
    private bool running = true;
    const string SSDP_ADDR = "172.16.31.10";
    private static readonly IPEndPoint SSDP_ENDP = new IPEndPoint(IPAddress.Parse(SSDP_ADDR), SSDP_PORT);
    private static readonly IPAddress SSDP_IP = IPAddress.Parse(SSDP_ADDR);
    const int SSDP_PORT = 1900;



    public SsdpHandler()
    {
      notificationTimer.Elapsed += Tick;
      notificationTimer.Enabled = true;

      queueTimer.Elapsed += ProcessQueue;

      client.Client.UseOnlyOverlappedIO = true;
      client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
      client.ExclusiveAddressUse = false;
      client.Client.Bind(new IPEndPoint(IPAddress.Any, SSDP_PORT));
{'fraction_non_alphanumeric': 0.08715050565139798, 'fraction_numerical': 0.013979773944080905, 'mean_word_length': 4.633165829145729, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4502297', 'n_tokens_mistral': 1040, 'n_tokens_neox': 980, 'n_words': 249}