System.Net.Sockets.Socket.SetToDisconnected C# (CSharp) Method

SetToDisconnected() private method

private SetToDisconnected ( ) : void
return void
        internal void SetToDisconnected()
        {
            if (NetEventSource.IsEnabled) NetEventSource.Enter(this);

            if (!_isConnected)
            {
                // Socket was already disconnected.
                return;
            }

            // Update the status: this socket was indeed disconnected at
            // some point in time, clear any async select bits.
            _isConnected = false;
            _isDisconnected = true;

            if (!CleanedUp)
            {
                // If socket is still alive cancel WSAEventSelect().
                if (NetEventSource.IsEnabled) NetEventSource.Info(this, "!CleanedUp");
            }
        }

Usage Example

        //
        // This method will be called by us when the IO completes synchronously and
        // by the ThreadPool when the IO completes asynchronously. (only called on WinNT)
        //

        internal override object PostCompletion(int numBytes)
        {
            if (ErrorCode == (int)SocketError.Success)
            {
                Socket socket = (Socket)AsyncObject;
                socket.SetToDisconnected();
                socket.m_RemoteEndPoint = null;
            }
            return(base.PostCompletion(numBytes));
        }
All Usage Examples Of System.Net.Sockets.Socket::SetToDisconnected