private State DoDisconnect() { logger.Site().Debug("{0} Shutting down.", this); networkStream.Shutdown(); if (connectionType == ConnectionType.Server) { parentListener.InformDisconnected(this, errorDetails); } responseMap.Shutdown(); return(State.Disconnected); }
private void ShutdownSocketSafe(Socket socket, EpoxyNetworkStream epoxyStream) { if (epoxyStream != null) { epoxyStream.Shutdown(); // epoxyStream owns the socket, so we shouldn't try to shutdown socket = null; } try { socket?.Shutdown(SocketShutdown.Both); socket?.Close(); } catch (SocketException ex) { // We tried to cleanly shutdown the socket, oh well. logger.Site().Debug(ex, "Exception encountered when shutting down a socket."); } }