private void SendBuffer(uint nIP, ushort nPort, byte[] pPacket, uint uSize) { // ZZ:UploadBandWithThrottler (UDP) -. ServerUDPPacket newpending = new ServerUDPPacket(); newpending.dwIP = nIP; newpending.nPort = nPort; newpending.packet = pPacket; newpending.size = (int)uSize; lock (sendLocker_) { controlpacketQueue_.Add(newpending); }// sendLocker.Unlock(); MuleApplication.Instance.UploadBandwidthThrottler.QueueForSendingControlPacket(this); // <-- ZZ:UploadBandWithThrottler (UDP) }
public SocketSentBytes SendControlData(uint maxNumberOfBytesToSend, uint minFragSize) { // ZZ:UploadBandWithThrottler (UDP) -. // NOTE: *** This function is invoked from a *different* thread! uint sentBytes = 0; lock (sendLocker_) { // <-- ZZ:UploadBandWithThrottler (UDP) while (controlpacketQueue_.Count > 0 && sentBytes < maxNumberOfBytesToSend) // ZZ:UploadBandWithThrottler (UDP) { ServerUDPPacket packet = controlpacketQueue_[0]; int sendSuccess = UDPSendTo(packet.packet, packet.size, packet.dwIP, packet.nPort); if (sendSuccess >= 0) { if (sendSuccess > 0) { sentBytes += (uint)packet.size; // ZZ:UploadBandWithThrottler (UDP) } controlpacketQueue_.RemoveAt(0); } } // ZZ:UploadBandWithThrottler (UDP) -. if (controlpacketQueue_.Count > 0) { MuleApplication.Instance.UploadBandwidthThrottler.QueueForSendingControlPacket(this); } }//sendLocker.Unlock(); SocketSentBytes returnVal = new SocketSentBytes(true, 0, sentBytes); return(returnVal); // <-- ZZ:UploadBandWithThrottler (UDP) }