<commit_before>using System;
using System.Net;
using System.Net.Sockets;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using Common.Logging;
using GT.Utils;

namespace GT.Net
{

    /// <summary>
    /// Class responsible for connecting (and negotiating) a connection to a
    /// remote server using UDP.
    /// </summary>
    /// <remarks>
    /// The use of <see cref="TransportFactory{T}"/> may seem to be a bit complicated,
    /// but it greatly simplifies testing.
    /// </remarks>
    public class UdpConnector : IConnector
    {
        protected ILog log;

        protected bool active = false;
        protected TransportFactory<UdpClient> factory;

        /// <summary>
        /// The default constructor is for an unordered, unsequenced UDP
        /// </summary>
        public UdpConnector() : this(Ordering.Unordered) {}

        public UdpConnector(Ordering ordering)
        {
            log = LogManager.GetLogger(GetType());

            switch (ordering)
            {
                case Ordering.Unordered:
                    factory = new TransportFactory<UdpClient>(
                        BaseUdpTransport.UnorderedProtocolDescriptor,
                        h => new UdpClientTransport(h),
                        t => t is UdpClientTransport);
                    return;
                case Ordering.Sequenced:
                    factory = new TransportFactory<UdpClient>(
                        BaseUdpTransport.SequencedProtocolDescriptor,
                        h => new UdpSequencedClientTransport(h),
                        t => t is UdpSequencedClientTransport);
                    return;
                default: throw new InvalidOperationException("Unsupported ordering type: " + ordering);
            }
        }

        public UdpConnector(TransportFactory<UdpClient> factory)
        {
            this.factory = factory;
        }

        public byte[] ProtocolDescriptor
        {<commit_msg>Fixed bug in UdpConnector arising from logging changes revealed by sequenced UDP: there are two code paths through the constructor.<commit_after>using System;
using System.Net;
using System.Net.Sockets;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using Common.Logging;
using GT.Utils;

namespace GT.Net
{

    /// <summary>
    /// Class responsible for connecting (and negotiating) a connection to a
    /// remote server using UDP.
    /// </summary>
    /// <remarks>
    /// The use of <see cref="TransportFactory{T}"/> may seem to be a bit complicated,
    /// but it greatly simplifies testing.
    /// </remarks>
    public class UdpConnector : IConnector
    {
        protected ILog log;

        protected bool active = false;
        protected TransportFactory<UdpClient> factory;

        /// <summary>
        /// The default constructor is for an unordered, unsequenced UDP
        /// </summary>
        public UdpConnector() : this(Ordering.Unordered) {}

        public UdpConnector(Ordering ordering)
        {
            log = LogManager.GetLogger(GetType());

            switch (ordering)
            {
                case Ordering.Unordered:
                    factory = new TransportFactory<UdpClient>(
                        BaseUdpTransport.UnorderedProtocolDescriptor,
                        h => new UdpClientTransport(h),
                        t => t is UdpClientTransport);
                    return;
                case Ordering.Sequenced:
                    factory = new TransportFactory<UdpClient>(
                        BaseUdpTransport.SequencedProtocolDescriptor,
                        h => new UdpSequencedClientTransport(h),
                        t => t is UdpSequencedClientTransport);
                    return;
                default: throw new InvalidOperationException("Unsupported ordering type: " + ordering);
            }
        }

        public UdpConnector(TransportFactory<UdpClient> factory)
        {
            log = LogManager.GetLogger(GetType());

            this.factory = factory;
        }

        public byte[] ProtocolDescriptor
        {
{'fraction_non_alphanumeric': 0.08478260869565217, 'fraction_numerical': 0.0, 'mean_word_length': 1.8017591339648173, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5607889', 'n_tokens_mistral': 1004, 'n_tokens_neox': 970, 'n_words': 283}