MCPcopy Create free account
hub / github.com/curtcox/JLHTTP / start

Method start

src/main/java/net/freeutils/httpserver/HTTPServer.java:2030–2044  ·  view source on GitHub ↗

Starts this server. If it is already started, does nothing. Note: Once the server is started, configuration-altering methods of the server and its virtual hosts must not be used. To modify the configuration, the server must first be stopped. @throws IOException if the server cannot begin accepting

()

Source from the content-addressed store, hash-verified

2028 * @throws IOException if the server cannot begin accepting connections
2029 */
2030 public synchronized void start() throws IOException {
2031 if (serv != null)
2032 return;
2033 if (serverSocketFactory == null) // assign default server socket factory if needed
2034 serverSocketFactory = ServerSocketFactory.getDefault(); // plain sockets
2035 serv = createServerSocket();
2036 if (executor == null) // assign default executor if needed
2037 executor = Executors.newCachedThreadPool(); // consumes no resources when idle
2038 // register all host aliases (which may have been modified)
2039 for (VirtualHost host : getVirtualHosts())
2040 for (String alias : host.getAliases())
2041 hosts.put(alias, host);
2042 // start handling incoming connections
2043 new SocketHandlerThread().start();
2044 }
2045
2046 /**
2047 * Stops this server. If it is already stopped, does nothing.

Callers 1

mainMethod · 0.95

Calls 3

createServerSocketMethod · 0.95
getVirtualHostsMethod · 0.95
getAliasesMethod · 0.80

Tested by

no test coverage detected