Beispiel #1
0
        private void CompleteSend(SocketAsyncEventArgs args, bool executeLoop = false)
        {
            if (args.SocketError != SocketError.Success)
            {
                var exception = new SocketException((int)args.SocketError);
                amqpConnection.NotifyIoException(exception);
                return; // no more sending
            }

            var sendState = sendEventArgs.UserToken as SendAsyncState;

            int sentCount = args.BytesTransferred;

            sendState.countToWrite -= sentCount;
            sendState.byteBuffer.CompleteRead(sentCount);

            trace.Debug("Sent {0} bytes on socket", sentCount.ToString());

            if (sendState.countToWrite <= 0)
            {
                // all bytes sent
                sendState.sendCompleteCallback();
                return;
            }

            // more bytes to send
            if (sendState.countToWrite > 0 && executeLoop)
            {
                SendAsyncLoop(sendState);
            }
        }