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

FinishOperationSyncFailure() private method

private FinishOperationSyncFailure ( SocketError socketError, int bytesTransferred, SocketFlags flags ) : void
socketError SocketError
bytesTransferred int
flags SocketFlags
return void
        internal void FinishOperationSyncFailure(SocketError socketError, int bytesTransferred, SocketFlags flags)
        {
            SetResults(socketError, bytesTransferred, flags);

            // This will be null if we're doing a static ConnectAsync to a DnsEndPoint with AddressFamily.Unspecified;
            // the attempt socket will be closed anyways, so not updating the state is OK.
            if (_currentSocket != null)
            {
                _currentSocket.UpdateStatusAfterSocketError(socketError);
            }

            Complete();
        }

Usage Example

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

            if (s_loggingEnabled)
            {
                 Logging.Enter(Logging.Sockets, this, "DisconnectAsync", "");
            }

            if (CleanedUp)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

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

            // Make the native call.
            SocketError socketError = SocketError.Success;
            try
            {
                socketError = e.DoOperationDisconnect(this, _handle);
            }
            catch (Exception ex)
            {
                // Clear in-use flag on event args 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::FinishOperationSyncFailure
SocketAsyncEventArgs