Environment
- Android Studio latest release
- Android Emulator running Android Nougat
- MAMP to serve as HTTP server
Problem
My simple method
Future<String> _getSimpleReply( String command, callback, errorCallback ) async {
try {
HttpClientRequest request = await _myClient.get( '127.0.0.1', 80 '/' );
HttpClientResponse response = await request.close();
await callback( response.toString() );
} on SocketException catch( e ) {
errorCallback( e.toString() );
}
}
fails with an error:
cbLoginFailed :: SocketException: OS Error:
Connection refused, errno = 111, address = 127.0.0.1, port = 46414
Currently using the Android emulator, which has been configured for internet access:
<uses-permission android:name="android.permission.INTERNET"/>
For test purpose, the HTTP server is MAMP, which executes the index.php script and returns some simple string, if I enter this link in a browser:
http://127.0.0.1/index.php
The situation does not change, if I replace 127.0.0.1 with localhost.
But if I do change 127.0.0.1 with a valid public FQDN, the method works just fine:
doLoginSuccess :: Instance of '_HttpClientResponse'
Question
Why does the android emulator / flutter / dart handles 127.0.0.1 different than a valid FQDN?
And how to I change this behaviour?