Example #1
0
        /// <inheritdoc />
        /// <remarks>
        /// <inheritdoc />
        /// <para>This method is a noop if the socket was never connected.</para>
        /// </remarks>
        public void Close()
        {
            // Do nothing if the underlying socket isn't there.
            if (Socket_ == null)
            {
                return;
            }

            // Disconnect all socket events
            DisconnectSocketEvents();

            // By default, closing the socket handle will cause the socket to linger
            Socket_.Dispose();

            // GC won't abort the graceful closure, because the WinSock API will keep it alive for a time
            Socket_ = null;
        }
Example #2
0
        /// <inheritdoc />
        /// <remarks>
        /// <inheritdoc />
        /// <para>This method is a noop if the socket was never connected.</para>
        /// </remarks>
        public void AbortiveClose()
        {
            // Do nothing if the underlying socket isn't there.
            if (Socket_ == null)
            {
                return;
            }

            // Disconnect all socket events
            DisconnectSocketEvents();

            // Set up the socket for an abortive close.
            Socket_.SetAbortive();

            // Close the socket connection
            Socket_.Dispose();
            Socket_ = null;
        }
Example #3
0
        /// <inheritdoc />
        /// <remarks>
        /// <inheritdoc />
        /// <para>This method is a noop if the socket was never connected.</para>
        /// </remarks>
        public void Close()
        {
            // Do nothing if the underlying socket isn't there.
            if (Socket_ == null)
                return;

            // Disconnect all socket events
            DisconnectSocketEvents();

            // By default, closing the socket handle will cause the socket to linger
            Socket_.Dispose();

            // GC won't abort the graceful closure, because the WinSock API will keep it alive for a time
            Socket_ = null;
        }
Example #4
0
        /// <inheritdoc />
        /// <remarks>
        /// <inheritdoc />
        /// <para>This method is a noop if the socket was never connected.</para>
        /// </remarks>
        public void AbortiveClose()
        {
            // Do nothing if the underlying socket isn't there.
            if (Socket_ == null)
                return;

            // Disconnect all socket events
            DisconnectSocketEvents();

            // Set up the socket for an abortive close.
            Socket_.SetAbortive();

            // Close the socket connection
            Socket_.Dispose();
            Socket_ = null;
        }