/// <summary> /// Closes and disposes of a Request and its Socket while also removing it from the internal collection of open sockets. /// </summary> private void OnNormalSocketClose(Socket sock, FosRequest fosRequest) { if (fosRequest == null) { throw new ArgumentNullException("fosRequest"); } //TODO: We should make sure that this method never gets called if OnAbruptSocketClose was called. // This is just a staple solution, it is subject to race conditions FosRequest trash; if (OpenSockets.TryRemove(sock, out trash) && Logger != null) { Logger.LogConnectionEndedNormally(sock, new RequestInfo(fosRequest)); } }