예제 #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 = SendBuffer.ReadAll();
            SocketSendEvent(sendBytes);
            SendBuffer.MoveReadPosition(length);
        }