System.Net.Sockets.SocketAsyncEventArgs.StartOperationDisconnect C# (CSharp) Method

StartOperationDisconnect() private method

private StartOperationDisconnect ( ) : void
return void
        internal void StartOperationDisconnect()
        {
            // Remember the operation type.
            _completedOperation = SocketAsyncOperation.Disconnect;
            InnerStartOperationDisconnect();
        }

Usage Example

Example #1
0
        //
        // DisconnectAsync
        // 
        public bool DisconnectAsync(SocketAsyncEventArgs e) {

            bool retval;
            
            if(s_LoggingEnabled) Logging.Enter(Logging.Sockets, this, "DisconnectAsync", "");

            // Throw if socket disposed
            if(CleanedUp) {
                throw new ObjectDisposedException(GetType().FullName);
            }

            // Prepare for the native call.
            e.StartOperationCommon(this);
            e.StartOperationDisconnect();
            BindToCompletionPort();

            // Make the native call.
            SocketError socketError = SocketError.Success;
            try {
                if(!DisconnectEx(
                        m_Handle,
                        e.m_PtrNativeOverlapped,
                        (int)(e.DisconnectReuseSocket ? TransmitFileOptions.ReuseSocket : 0),
                        0)) {
                    socketError = (SocketError)Marshal.GetLastWin32Error();
                }
            }
            catch(Exception ex) {
                // clear in-use on event arg object 
                e.Complete();
                throw ex;
            }

            // Handle completion when completion port is not posted.
            if(socketError != SocketError.Success && socketError != SocketError.IOPending) {
                e.FinishOperationSyncFailure(socketError, 0, SocketFlags.None);
                retval = false;
            } else {
                retval = true;
            }

            if(s_LoggingEnabled) Logging.Exit(Logging.Sockets, this, "DisconnectAsync", retval);

            return retval;
        }
All Usage Examples Of System.Net.Sockets.SocketAsyncEventArgs::StartOperationDisconnect
SocketAsyncEventArgs