public void Disconnect() { // complete the blocking collection queue.Complete(); // We want to clean up the connection here so let's just try to close/dispose // everything // Analysis disable EmptyGeneralCatchClause try { clientStream.Close(); } catch { } try { clientStream.Dispose(); } catch { } if (ConnectionSettings.UseTls && sslStream != null) { try { sslStream.Close(); } catch { } try { sslStream.Dispose(); } catch { } } try { tcp.Client.Shutdown(SocketShutdown.Both); } catch { } try { tcp.Client.Dispose(); } catch { } try { tcp.Close(); } catch { } // Analysis restore EmptyGeneralCatchClause tcp = null; sslStream = null; clientStream = null; }
public void Disconnect() { // complete the blocking collection queue.Complete(); //We now expect apple to close the connection on us anyway, so let's try and close things // up here as well to get a head start //Hopefully this way we have less messages written to the stream that we have to requeue try { clientStream.Close(); } catch { } try { clientStream.Dispose(); } catch { } if (ConnectionSettings.UseTls && sslStream != null) { try { sslStream.Close(); } catch { } try { sslStream.Dispose(); } catch { } } try { tcp.Client.Shutdown(SocketShutdown.Both); } catch { } try { tcp.Client.Dispose(); } catch { } try { tcp.Close(); } catch { } tcp = null; sslStream = null; clientStream = null; }