Does Kotlin native have support for any IPC mechan...
# kotlin-native
v
Does Kotlin native have support for any IPC mechanism in the Linux platform? Like D-Bus. I can see that ktor has a socket but I'm just looking is there any high level IPC that exists like D-Bus, Grpc or something else.
e
You can use all the Posix directly.
v
You mean binding POSIX D-Bus C API to Kotlin native? Or the bindings already available via platform libs?
e
I have not seen hand-crafted Kotlin bindings, but C APIs like D-Bus should be directly usable from Kotlin/Native via cinterop, just like all other C libraries.
v
Alright, just one last question. If I create a Kotlin native lib and it is going to be used via C then the Kotlin lib interface should not contain any suspend function as API isn't it? Because I see that suspend functions are exposed to objective-C via some Callback Handler, so is there any magic 🪄 similar to that for "C" 😁?
e
Yes, for C APIs you should provide some C-style async (via completion callbacks maybe?)
v
Is there any example for this somewhere? If not I'll try myself later 🙂 Thanks for your comments
e
Cannot think of any. It really depends on the style of C ecosystem you are planning to interact with.
v
But in any case, if I want to expose Kotlin native API to "C" then I need to auto generate "C" headers for those Kotlin APIs, but the auto generator will simply ignore the API if it's marked as suspend right?
a
I suspect that suspend functions are not ignored, but try giving it a go and report back :) https://kotlinlang.org/docs/native-dynamic-libraries.html At least for Objective-C they are generated https://kotlinlang.org/docs/native-objc-interop.html#suspending-functions
v
Yep! My guess was correct. I just made the functions in these examples ( https://kotlinlang.org/docs/native-dynamic-libraries.html )as suspend and the generator just ignores those functions. Now I'm thinking of adding those functions with callbacks and trying to communicate from C 🤔
167 Views