The device does have network connectivity (WiFi and 3G).
C开发者_StackOverflow中文版alling gethostbyname() returns NULL with errno 111 (ECONNREFUSED).
The same call works fine on osx and windows.
What could be the problem?
Best,
You should add permission to use Internet in your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
The problem is most likely a not or wrong configured DNS server setting on your device. Be sure to check that. This is most probably a problem with your local WiFi network - probably there's no local DNS server.
Maybe you could also try disabling WiFi as DNS resolution should work automatically in your mobile network.
ECONNREFUSED
suggests that the DNS resolver on your device may have tried failing over to TCP/IP (instead of UDP) because the answer was too long to fit in a normal UDP response packet.
If the configured DNS servers don't support inbound DNS requests over TCP you'd get that error.
Client apps can't normally get ECONNREFUSED
from a UDP socket because they're stateless.
精彩评论