예제 #1
0
        /// <summary>
        /// This method is called whenever a receive or send operation is completed on a socket
        /// </summary>
        private void IO_Completed(object sender, SocketAsyncEventArgs e)
        {
            // determine which type of operation just completed and call the associated handler
            switch (e.LastOperation)
            {
            case SocketAsyncOperation.Receive:
                _context.Post(ProcessReceive, e);
                break;

            case SocketAsyncOperation.Send:
                _context.Post(ProcessSend, e);
                break;

            default:
                throw new ArgumentException("The last operation completed on the socket was not a receive or send");
            }
        }
예제 #2
0
        private void AcceptEventArg_Completed(object sender, SocketAsyncEventArgs e)
        {
            switch (e.LastOperation)
            {
            case SocketAsyncOperation.Connect:
                _syncContext.Post(ProcessConnected, e);
                break;

            default:
                throw new ArgumentException("The last operation completed on the socket was not a connect");
            }
        }