vendredi 17 mai 2019

How to connect to the localhost of an Android emulator?

Note that I'm not trying to connect to the localhost of the host machine from the Android emulator, I'm pretty much doing it in reverse - I started a server on the localhost inside Android emulator and want to connect to that localhost from the computer's browser.

I'm using Angel framework on Flutter.

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';

Future<AngelHttp> startWebServer({int port = 3000}) async {
  var app = Angel();
  var http = AngelHttp(app);

  await http.startServer('localhost', port);
  print('Started HTTP server at ${http.server.address}:${http.server.port}');

  app.get('/', (req, res) => res.write('<p>Hello, world!<p>'));

  return http;
}

What settings should I put and what address should I use in my browser to receive 'Hello World' from the server running on the emulator?




Aucun commentaire:

Enregistrer un commentaire