/** * Forcibly closes all connections that are open. */ public synchronized void closeAllConnections() { for (Socket socket : openConnections) { safeClose(socket); } }
/** * Forcibly closes all connections that are open. */ public synchronized void closeAllConnections() { for (Socket socket : openConnections) { safeClose(socket); } }
/** * Stop the server. */ public void stop() { try { safeClose(myServerSocket); myThread.join(); } catch (Exception e) { e.printStackTrace(); } }
/** * Stop the server. */ public void stop() { try { safeClose(myServerSocket); closeAllConnections(); if (myThread != null) { myThread.join(); } } catch (Exception e) { e.printStackTrace(); } }
/** * Stop the server. */ public void stop() { try { safeClose(this.myServerSocket); this.asyncRunner.closeAll(); if (this.myThread != null) { this.myThread.join(); } } catch (Exception e) { NanoHTTPD.LOG.log(Level.SEVERE, "Could not stop all connections", e); } }
/** * Stop the server. */ public void stop() { try { safeClose(myServerSocket); closeAllConnections(); if (myThread != null) { myThread.join(); } } catch (Exception e) { e.printStackTrace(); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void loadMimeTypes(Map<String, String> result, String resourceName) { try { Enumeration<URL> resources = NanoHTTPD.class.getClassLoader().getResources(resourceName); while (resources.hasMoreElements()) { URL url = (URL) resources.nextElement(); Properties properties = new Properties(); InputStream stream = null; try { stream = url.openStream(); properties.load(stream); } catch (IOException e) { LOG.log(Level.SEVERE, "could not load mimetypes from " + url, e); } finally { safeClose(stream); } result.putAll((Map) properties); } } catch (IOException e) { LOG.log(Level.INFO, "no mime types available at " + resourceName); } };