예제 #1
0
        public UdpConnectionListener2(IPEndPoint endPoint, ILogger logger, IPMode ipMode = IPMode.IPv4)
        {
            this.Logger   = logger;
            this.EndPoint = endPoint;
            this.IPMode   = ipMode;

            this.socket          = UdpConnection.CreateSocket(this.IPMode);
            this.socket.Blocking = false;

            this.socket.ReceiveBufferSize = SendReceiveBufferSize;
            this.socket.SendBufferSize    = SendReceiveBufferSize;

            this.reliablePacketThread = new Thread(ManageReliablePackets);
            this.sendThread           = new Thread(SendLoop);
            this.receiveThread        = new Thread(ReceiveLoop);
            this.processThreads       = new HazelThreadPool(4, ProcessingLoop);
        }
예제 #2
0
        public ThreadLimitedUdpConnectionListener(int numWorkers, IPEndPoint endPoint, ILogger logger, IPMode ipMode = IPMode.IPv4)
        {
            this.Logger   = logger;
            this.EndPoint = endPoint;
            this.IPMode   = ipMode;

            this.receiveQueue = new BlockingCollection <ReceiveMessageInfo>(10000);

            this.socket = UdpConnection.CreateSocket(this.IPMode);
            this.socket.ExclusiveAddressUse = true;
            this.socket.Blocking            = false;

            this.socket.ReceiveBufferSize = SendReceiveBufferSize;
            this.socket.SendBufferSize    = SendReceiveBufferSize;

            this.reliablePacketThread = new Thread(ManageReliablePackets);
            this.sendThread           = new Thread(SendLoop);
            this.receiveThread        = new Thread(ReceiveLoop);
            this.processThreads       = new HazelThreadPool(numWorkers, ProcessingLoop);
        }