예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private IAsyncResult BeginReceiveFrom()
        {
            NetworkBuffer    buffer  = new NetworkBuffer(this.socket, this.mtu);
            AsyncReceiveFrom asyncOp = new AsyncReceiveFrom(buffer, ReceiveFromHandler);

            asyncOp.BeginReceiveFrom(SocketFlags.None);
            return(asyncOp);
        }
예제 #2
0
        /// <summary>
        /// Processes the receive from completion.
        /// </summary>
        /// <param name="asyncResult">The asynchronous result.</param>
        private void ReceiveFromCallback(IAsyncResult asyncResult)
        {
            AsyncReceiveFrom asyncOp = asyncResult.AsyncState as AsyncReceiveFrom;

            try
            {
                asyncOp.buffer.EndReceiveFrom(asyncResult);

                asyncOp.SetComplete(asyncResult.CompletedSynchronously);
            }
            catch (ObjectDisposedException)
            {
            }
            catch (Exception ex)
            {
                asyncOp.SetComplete(asyncResult.CompletedSynchronously, ex);
            }
        }