Esempio n. 1
0
        static private void ReceiveThread(object Param)
        {
            Logger.WriteLine($"Receive thread started with id {Task.CurrentId}");
            SharedObject data = (SharedObject)Param;

            while (!data.Ended)
            {
                data.Socket.ReceiveTimeout = (int)PacketsProps.WAIT_TIME;
                try
                {
                    CommunicationPacket p = CommunicationFacade.Receive(data.Socket);
                    UInt64 currentPoint;
                    lock (data.CountersLocker)
                        currentPoint = data.Confirmed;

                    UInt64           confirmationNumber = CommunicationFacade.ComputeRealNumber(p.ConfirmationNumber, currentPoint, UInt16.MaxValue, (uint)Sizes.WINDOW_SIZE);
                    UploadRecvPacket recv = new UploadRecvPacket(p.ConnectionNumber, p.Flags, p.Data, confirmationNumber);

                    lock (data.ArriveQueue)
                        data.ArriveQueue.Enqueue(recv);
                }
                catch (SocketException e) when(e.SocketErrorCode == SocketError.TimedOut)
                {
                }
            }
        }
Esempio n. 2
0
        private DownloadPacket receive(CommunicationPacket p)
        {
            UInt64         realSerial = CommunicationFacade.ComputeRealNumber(p.SerialNumber, this.required, UInt16.MaxValue, (uint)Sizes.WINDOW_SIZE);
            DownloadPacket toReturn   = new DownloadPacket(p.Data, p.ConnectionNumber, p.Flags, realSerial);;

            Logger.WriteLine($"Downloader recive packet with serial={toReturn.SerialNumber}");
            return(toReturn);
        }