private bool TrySetShutdown(PipeShutdownKind kind, SocketError socketError) { var win = TrySetShutdown(kind); if (win) { SocketError = socketError; } return(win); }
/// <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); } }
private bool TrySetShutdown(Exception ex, PipeShutdownKind kind) { try { return(ex is SocketException se? TrySetShutdown(kind, se.SocketErrorCode) : TrySetShutdown(kind)); } catch { return(false); } }
private bool TrySetShutdown(PipeShutdownKind kind) { return(kind != PipeShutdownKind.None && Interlocked.CompareExchange(ref _socketShutdownKind, (int)kind, 0) == 0); }