import 'dart:io';
import 'dart:isolate';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
shelf.Response _echoRequest(shelf.Request request) =>
new shelf.Response.ok('Request for "${request.url}"');
main() async {
var isolates = 4;
for (int i = 1; i < isolates; i++) {
Isolate.spawn(_startServer, []);
}
_startServer();
}
_startServer([args]) async {
var server =
await HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8080, shared: true);
io.serveRequests(server, _echoRequest);
}
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
There's no need to use shelf. https://github.com/costajob/app-servers/pull/23
You received this message because you are subscribed to a topic in the Google Groups "Dart Misc" group.
To unsubscribe from this topic, visit https://groups.google.com/a/dartlang.org/d/topic/misc/Ju4f2d5ziwE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to misc+uns...@dartlang.org.
I'll put up a PR when I have a moment, or if someone can beat me to it: note that the sample put up oddly subtracts one from the number of isolates in the for loop, so just updating that isolate count variable isn't accurate.