Search code examples
androidsocketsunixlocalsocket

Can I use a Unix domain socket on Android?


Can I use a Unix domain socket on Android (both server and client on the same Android device, for IPC)? Or, must I use LocalSocket?


Solution

  • LocalSocket and LocalServerSocket uses Unix domain sockets internally.

    https://developer.android.com/reference/android/net/LocalSocket

    Creates a (non-server) socket in the UNIX-domain namespace.

    https://developer.android.com/reference/android/net/LocalServerSocket

    Non-standard class for creating an inbound UNIX-domain socket in the Linux abstract namespace.

    Also see: Android create Unix domain socket by bound file descriptor