title: "flutter (os error: no address associated with hostname, errno = 7)" only for android
body: <p>I created a DNS server in esp32 wifi module (arduino framework) to communicate with flutter app. It working correctly in dart and flutter ios app but its not working with flutter andoid app. I am getting the following error in flutter android "flutter (os error: no address associated with hostname, errno = 7)". Since it is working perfectly with dart and ios flutter app I hope its not the esp32 wifi program error. I think its problem with flutter andoid. I tried the methods posted in "<a href="https://github.com/flutter/flutter/issues/27883" rel="noreferrer">https://github.com/flutter/flutter/issues/27883</a>" and is also not working in my case. So please help me to solve this issue.</p>
  
  <p><a href="https://github.com/flutter/flutter/issues/27883" rel="noreferrer">https://github.com/flutter/flutter/issues/27883</a></p>
  
  <p>ESP32 code</p>
  
  <hr>
  
  <pre><code>#include &lt;WiFi.h&gt;
  #include &lt;ESPmDNS.h&gt;
  #include &lt;WiFiClient.h&gt;
  
  WiFiServer wifiServer(80);
  
  String hostname="esp32";
  
  const char* ssid = "ssid";
  const char* password =  "password";
  
  void setup() {
    Serial.begin(115200);
  
    WiFi.mode(WIFI_AP);
    WiFi.begin(ssid, password);
    WiFi.setHostname("toyama");
    Serial.printf("Connecting to ssid '%s'", ssid);
    Serial.println();
    while (WiFi.status() != WL_CONNECTED)
    {
      delay(500);
      Serial.print(".");
    }
    Serial.printf("\nWiFi connected to '%s'", WiFi.SSID().c_str());
    Serial.println();
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
  
    if (!MDNS.begin(hostname.c_str())) {
      Serial.println("Error setting up MDNS responder!");
      while (1) {
        delay(1000);
      }
    }
    Serial.printf("mDNS responder started at %s.local:80\n",hostname.c_str());
  
    // Start TCP (HTTP) server
    wifiServer.begin();
  
    // Add service to MDNS-SD
    MDNS.addService("http", "tcp", 80);
    Serial.print("Server started at ");
    Serial.print(WiFi.localIP());
    Serial.println(":80");
  
  }
  
  void loop()
  {
    WiFiClient client = wifiServer.available();
  
    if (client) {
      Serial.println("Client connected");
      while (client.connected()) {
  
        if (client.available() &gt; 0) {
          String c = client.readString();
          Serial.print(client.remoteIP().toString());
          Serial.print(":");
          Serial.print(c);
        }
  
        if (Serial.available() &gt; 0)
        {
          String ch = Serial.readString();
          client.println(ch);
          Serial.print(WiFi.localIP());
          Serial.print(":");
          Serial.println(ch);
        }
      }
  
      client.stop();
      Serial.println("Client disconnected");
  
    }
  }
  </code></pre>
  
  <p>Flutter code</p>
  
  <hr>
  
  <pre><code>import 'package:flutter/foundation.dart';
  import 'dart:io';
  import 'package:flutter/material.dart';
  
  void main() async {
    // modify with your true address/port
    Socket sock = await Socket.connect("esp32.local", 80);
    runApp(MyApp(sock));
  }
  
  class MyApp extends StatelessWidget {
    Socket socket;
  
    MyApp(Socket s) {
      this.socket = s;
    }
  
    @override
    Widget build(BuildContext context) {
      final title = 'TcpSocket Demo';
      return MaterialApp(
        title: title,
        home: MyHomePage(
          title: title,
          channel: socket,
        ),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    final String title;
    final Socket channel;
  
    MyHomePage({Key key, @required this.title, @required this.channel})
        : super(key: key);
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    TextEditingController _controller = TextEditingController();
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Padding(
          padding: const EdgeInsets.all(20.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: &lt;Widget&gt;[
              Form(
                child: TextFormField(
                  controller: _controller,
                  decoration: InputDecoration(labelText: 'Send a message'),
                ),
              ),
              StreamBuilder(
                stream: widget.channel,
                builder: (context, snapshot) {
                  return Padding(
                    padding: const EdgeInsets.symmetric(vertical: 24.0),
                    child: Text(snapshot.hasData
                        ? '${String.fromCharCodes(snapshot.data)}'
                        : ''),
                  );
                },
              )
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _sendMessage,
          tooltip: 'Send message',
          child: Icon(Icons.send),
        ), // This trailing comma makes auto-formatting nicer for build methods.
      );
    }
  
    void _sendMessage() {
      if (_controller.text.isNotEmpty) {
        widget.channel.writeln(_controller.text);
      }
      // widget.channel.write('\n');
    }
  
    @override
    void dispose() {
      widget.channel.close();
      super.dispose();
    }
  }
  </code></pre>