Search code examples
androidandroid-ndksocketsgethostbyname

gethostbyname fails with error 111 (ECONNREFUSED)


The device does have network connectivity (WiFi and 3G).

Calling gethostbyname() returns NULL with errno 111 (ECONNREFUSED).

The same call works fine on osx and windows.

What could be the problem?

Best,


Solution

  • You should add permission to use Internet in your AndroidManifest.xml:

    <uses-permission android:name="android.permission.INTERNET"/>