예제 #1
0
 private void UploadLegacy( )
 {
     Debug.WriteLineIf(DccUtil.DccTrace.TraceInfo, "[" + Thread.CurrentThread.Name + "] DccFileSession::UploadLegacy()");
     try
     {
         int    bytesRead = 0;
         byte[] ack       = new byte[4];
         while ((bytesRead = dccFileInfo.TransferStream.Read(buffer, 0, buffer.Length)) != 0)
         {
             socket.Send(buffer, 0, bytesRead, SocketFlags.None);
             ResetActivityTimer();
             AddBytesProcessed(bytesRead);
             //Wait for acks from client
             socket.Receive(ack);
         }
         //Some IRC clients need a moment to catch up on their acks if our send buffer
         //is larger than their receive buffer. Test to make sure they ack all the bytes
         //before closing. This is only needed in legacy mode.
         while (!dccFileInfo.AcksFinished(DccUtil.DccBytesToLong(ack)))
         {
             socket.Receive(ack);
         }
         //Now we are done
         Finished();
     }
     catch (Exception e)
     {
         Debug.WriteLineIf(Rfc2812Util.IrcTrace.TraceWarning, "[" + Thread.CurrentThread.Name + "] DccFileSession::UploadLegacy() exception=" + e);
         Interrupted();
     }
 }