static void ProcessNotifyClockQueue(PseudoTcpSocket conn, Queue notifyClockQueue) { PLog.DEBUG("Entering ProcessNotifyClockQueue with queue size={0}", notifyClockQueue.Count); if (notifyClockQueue.Count != 0) { PLog.DEBUG("...and head timestamp={0}, current time={1}", notifyClockQueue.Peek(), Environment.TickCount); } if (notifyClockQueue.Count == 0) { UdpCallbacks.AdjustClock(conn, notifyClockQueue); return; } bool keepChecking = true; while (keepChecking && notifyClockQueue.Count > 0) { int iTimestamp = (int)notifyClockQueue.Peek(); if (Environment.TickCount > iTimestamp) { SyncPseudoTcpSocket.NotifyClock(conn); notifyClockQueue.Dequeue(); } else { keepChecking = false; } } }
static int SendFragment(PseudoTcpSocket conn, byte[] buffer, int fragmentSize, Queue notifyClockQueue) { int sent; do { PLog.DEBUG("Trying to send {0} bytes", fragmentSize); sent = SyncPseudoTcpSocket.Send(conn, buffer, (uint)fragmentSize); if (sent == -1) { PLog.DEBUG("sent==-1 so processing notifyClockQueue"); ProcessNotifyClockQueue(conn, notifyClockQueue); } else { UdpCallbacks.AdjustClock(conn, notifyClockQueue); } UdpCallbacks.PollingSleep(sent, -1); } while (sent == -1); PLog.DEBUG("Tried sending fragment sized {0} with result {1}", fragmentSize, sent); return(sent); }