private void HandleSendQueue() { QueuedPacket packet = null; lock (SyncLock) { packet = SendQueue.Dequeue(); } if (packet != null && packet.Data != null) { var se = SocketError.SocketError; NetworkSocket?.Send(packet.Data, 0, packet.Data.Length, SocketFlags.None, out se); if (se != SocketError.Success) { Disconnect(new SocketException()); return; } else { packet.HasBeenSent(this); } } }
private void HandleSend(object state) { if (SendQueue.Count == 0) { return; } byte[] payload; lock (_lock) { payload = SendQueue.Dequeue(); } NetworkSocket.Send(payload); }