예제 #1
0
        /// <summary>
        ///     Post a receive op.
        /// </summary>
        /// <param name="args"> </param>
        private void StartReceive(SocketAsyncEventArgs args)
        {
            // Post async receive operation on the socket.
            var willRaiseEvent = args.AcceptSocket.ReceiveAsync(args);

            // Socket.ReceiveAsync returns false if I/O operation completed synchronously.
            if (!willRaiseEvent)
            {
                // If the op completed synchronously, we need to call ProcessReceive method directly.
                Task.Run(() => ProcessReceive(args));
            }

            _monitor.StartReceive();
        }