public void Close() { prepare(); if (_request.GetResponse() == null) { OutboundStream.Close(); } _request.GetResponse().Close(); }
/// <summary> Closes streams and underlying socket. </summary> /// <seealso cref="Genetibase.NuGenHL7.protocol.StreamSource.disconnect()"> /// </seealso> public virtual void disconnect() { try { if (Connected) { OutboundStream.Close(); InboundStream.Close(); getSocket().Close(); } } catch (System.IO.IOException e) { throw new NuGenTransportException(e); } }
/// <summary> /// Closes the connection and cleans all the values related to the object. /// </summary> public async void Dispose() { if ((CancellationTokenSource != null) && (CancellationTokenSource.IsCancellationRequested)) { CancellationTokenSource.Cancel(); } if (InboundStream != null) { InboundStream.Dispose(); } if (OutboundStream != null) { OutboundStream.Dispose(); } if (StreamReader != null) { StreamReader.Dispose(); } if (StreamWriter != null) { StreamWriter.Dispose(); } if (Listener != null) { await Listener.CancelIOAsync(); Listener.ConnectionReceived -= Listener_ConnectionReceived; Listener.ConnectionReceived -= ConnectionReceived; Listener.Dispose(); } Listener = null; Port = -1; ErrorStatus = null; CancellationTokenSource = null; }