NLog.Internal.NetworkSenders.NetworkSender.Send C# (CSharp) Method

Send() public method

Send the given text over the specified protocol.
public Send ( byte bytes, int offset, int length, AsyncContinuation asyncContinuation ) : void
bytes byte Bytes to be sent.
offset int Offset in buffer.
length int Number of bytes to send.
asyncContinuation AsyncContinuation The asynchronous continuation.
return void
        public void Send(byte[] bytes, int offset, int length, AsyncContinuation asyncContinuation)
        {
            this.LastSendTime = Interlocked.Increment(ref currentSendTime);
            this.DoSend(bytes, offset, length, asyncContinuation);
        }

Usage Example

Example #1
0
        private void ChunkedSend(NetworkSender sender, byte[] buffer, AsyncContinuation continuation)
        {
            int tosend = buffer.Length;
            int pos = 0;

            AsyncContinuation sendNextChunk = null;

            sendNextChunk = ex =>
                {
                    if (ex != null)
                    {
                        continuation(ex);
                        return;
                    }

                    if (tosend <= 0)
                    {
                        continuation(null);
                        return;
                    }

                    int chunksize = tosend;
                    if (chunksize > this.MaxMessageSize)
                    {
                        if (this.OnOverflow == NetworkTargetOverflowAction.Discard)
                        {
                            continuation(null);
                            return;
                        }

                        if (this.OnOverflow == NetworkTargetOverflowAction.Error)
                        {
                            continuation(new OverflowException("Attempted to send a message larger than MaxMessageSize (" + this.MaxMessageSize + "). Actual size was: " + buffer.Length + ". Adjust OnOverflow and MaxMessageSize parameters accordingly."));
                            return;
                        }

                        chunksize = this.MaxMessageSize;
                    }

                    int pos0 = pos;
                    tosend -= chunksize;
                    pos += chunksize;

                    sender.Send(buffer, pos0, chunksize, sendNextChunk);
                };

            sendNextChunk(null);
        }
All Usage Examples Of NLog.Internal.NetworkSenders.NetworkSender::Send