Ejemplo n.º 1
0
        private void EndSend(IAsyncResult ar)
        {
            //User disconnect connection proactively
            if (!IsConnected)
            {
                return;
            }
            int length = 0;

            try
            {
                var socket = ar.AsyncState as Socket;
                AssertThat.IsNotNull(socket);
                length = socket.EndSend(ar);
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
            byte[] sendBytes = new byte[length];
            Array.Copy(SendBuffer.Array, SendBuffer.ReadPosition, sendBytes, 0, sendBytes.Length);
            SocketSendEvent(sendBytes);
            SendBuffer.MoveReadPosition(length);
        }