/// <summary> /// Closes the socket and sends the response if it was not done earlier /// and the socket is present. /// </summary> void IDisposable.Dispose() { if (!m_IsResponseClosed) { try { // Iterates over list of client connections and remove its stream from it. m_Listener.RemoveClientStream(m_clientStream); m_clientStream.Flush(); // If KeepAlive is true, if (m_KeepAlive) { // Then socket is tramsferred to the list of waiting for new data. m_Listener.AddToWaitingConnections(m_clientStream); } else // If not KeepAlive then close { m_clientStream.Dispose(); } } catch {} m_IsResponseClosed = true; } GC.SuppressFinalize(this); }