run method

Future<int> run()

Starts the Web server with HTTP.

For a secure HTTPS server, use runTLS instead.

This method will return a Future whose value is the total number of requests processed by the server. This value is only available if/when the server is cleanly stopped. But normally a server listens for requests "forever" and never stops.

Throws a StateError if the server is already running.

Implementation

Future<int> run() async {
  if (_svr != null) {
    throw StateError('server already running');
  }

  // Start the server

  // Normal HTTP bind

  if (bindPort < _minPort || _maxPort < bindPort) {
    bindPort = 80; // default HTTP port
  }

  final httpServer =
      await HttpServer.bind(bindAddress, bindPort, v6Only: v6Only);

  return _run(httpServer, isSecure: false);
}