Esempio n. 1
0
            public ReadDataAsyncResult(SizedTcpBaseChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;

                bool success = false;

                try
                {
                    IAsyncResult drainLengthResult = channel.BeginSocketReceiveBytes(4, false, OnDrainLength, this);
                    if (drainLengthResult.CompletedSynchronously)
                    {
                        if (CompleteDrainLength(drainLengthResult))
                        {
                            base.Complete(true);
                        }
                    }

                    success = true;
                }
                catch (CommunicationException e)
                {
                    base.Complete(true, e);
                }
                finally
                {
                    if (!success)
                    {
                        this.Cleanup();
                    }
                }
            }
Esempio n. 2
0
            public SocketReceiveAsyncResult(int size, bool throwOnEmpty, SizedTcpBaseChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.size           = size;
                this.channel        = channel;
                this.throwOnEmpty   = throwOnEmpty;
                this.bytesReadTotal = 0;
                this.buffer         = channel.bufferManager.TakeBuffer(size);

                bool success = false;

                try
                {
                    IAsyncResult socketReceiveResult = channel.BeginSocketReceive(this.buffer, bytesReadTotal, size, OnReadBytes, this);
                    if (socketReceiveResult.CompletedSynchronously)
                    {
                        if (CompleteReadBytes(socketReceiveResult))
                        {
                            base.Complete(true);
                        }
                    }
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        this.Cleanup();
                    }
                }
            }
Esempio n. 3
0
            public SocketSendAsyncResult(ArraySegment <byte> buffer, SizedTcpBaseChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;
                this.buffer  = buffer;

                this.StartSending();
            }
Esempio n. 4
0
            public ReadDataAsyncResult(SizedTcpBaseChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;

                bool success = false;
                try
                {
                    IAsyncResult drainLengthResult = channel.BeginSocketReceiveBytes(4, false, OnDrainLength, this);
                    if (drainLengthResult.CompletedSynchronously)
                    {
                        if (CompleteDrainLength(drainLengthResult))
                        {
                            base.Complete(true);
                        }
                    }

                    success = true;
                }
                catch (CommunicationException e)
                {
                    base.Complete(true, e);
                }
                finally
                {
                    if (!success)
                    {
                        this.Cleanup();
                    }
                }
            }
Esempio n. 5
0
            public SocketReceiveAsyncResult(int size, bool throwOnEmpty, SizedTcpBaseChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.size = size;
                this.channel = channel;
                this.throwOnEmpty = throwOnEmpty;
                this.bytesReadTotal = 0;
                this.buffer = channel.bufferManager.TakeBuffer(size);

                bool success = false;
                try
                {
                    IAsyncResult socketReceiveResult = channel.BeginSocketReceive(this.buffer, bytesReadTotal, size, OnReadBytes, this);
                    if (socketReceiveResult.CompletedSynchronously)
                    {
                        if (CompleteReadBytes(socketReceiveResult))
                        {
                            base.Complete(true);
                        }
                    }
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        this.Cleanup();
                    }
                }
            }
Esempio n. 6
0
            public SocketSendAsyncResult(ArraySegment<byte> buffer, SizedTcpBaseChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;
                this.buffer = buffer;

                this.StartSending();
            }