Beispiel #1
0
        private bool TrySetShutdown(PipeShutdownKind kind, SocketError socketError)
        {
            var win = TrySetShutdown(kind);

            if (win)
            {
                SocketError = socketError;
            }

            return(win);
        }
Beispiel #2
0
        /// <summary>
        /// Try to signal the pipe shutdown reason as being due to an application protocol event
        /// </summary>
        /// <param name="kind">The kind of shutdown; only protocol-related reasons will succeed</param>
        /// <returns>True if successful</returns>
        public bool TrySetProtocolShutdown(PipeShutdownKind kind)
        {
            switch (kind)
            {
            case PipeShutdownKind.ProtocolExitClient:
            case PipeShutdownKind.ProtocolExitServer:
                return(TrySetShutdown(kind));

            default:
                return(false);
            }
        }
Beispiel #3
0
 private bool TrySetShutdown(Exception ex, PipeShutdownKind kind)
 {
     try
     {
         return(ex is SocketException se?
                TrySetShutdown(kind, se.SocketErrorCode) : TrySetShutdown(kind));
     }
     catch
     {
         return(false);
     }
 }
Beispiel #4
0
 private bool TrySetShutdown(PipeShutdownKind kind)
 {
     return(kind != PipeShutdownKind.None &&
            Interlocked.CompareExchange(ref _socketShutdownKind, (int)kind, 0) == 0);
 }