Unix Domain Sockets API > 29

424 views
Skip to first unread message

mike mcnulty

unread,
Nov 27, 2023, 2:38:01 PM11/27/23
to android-ndk
Hello,

My team is trying to implement UDS in native C++ using API 33. When we try to bind our socket at address '\0program-uds' for example we get a bind: "Read-only file system error".

I can't find any recent documentation indicating that abstract UDS are still supported. 

Any help would be appreciated!

Dan Albert

unread,
Nov 27, 2023, 7:38:33 PM11/27/23
to andro...@googlegroups.com
https://github.com/android/ndk/issues/1469 was the previous time someone asked about this. I don't know if the OP ever followed through on that. I suspect the error message is the answer though.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1c79fb7d-f751-48e7-a75b-8f178db26b70n%40googlegroups.com.

mike mcnulty

unread,
Nov 28, 2023, 9:48:39 AM11/28/23
to android-ndk
For all that may come across this post in the future.

My team has successfully implemented UDS using native C++ API version 33.

Our particular problem was the null byte "\0" used to define our abstract UDS wasn't properly being passed from the JNI layer to our C++ application. At this time we are still hard coding the UDS path in native C++ to avoid this issue.

Thanks

Pete Bentley

unread,
Nov 28, 2023, 10:49:32 AM11/28/23
to andro...@googlegroups.com
> Our particular problem was the null byte "\0" used to define our abstract UDS wasn't properly being passed from the JNI layer to our C++ application

Without the '\0' then yeah, you're not in the abstract namespace and you're going to be subject to POSIX and SE Linux filesystem permissions.

If you're struggling to share the address between Java and native code, you could do worse than create it using UnixSocketAddress.createAbstract() and take a look at the platform code which converts to struct sockaddr used by methods such as android.system.Os.bind().


Phil Burk

unread,
Nov 28, 2023, 11:08:37 AM11/28/23
to andro...@googlegroups.com
> Our particular problem was the null byte "\0" used to define our abstract UDS wasn't properly being passed from the JNI layer to our C++ application.

Did you pass a numBytes of strlen(s) or (strlen(s)+1)?

Phil Burk



Reply all
Reply to author
Forward
0 new messages