Hi guys, new to KMP, we are doing a POC for a new ...
# multiplatform
i
Hi guys, new to KMP, we are doing a POC for a new product in our company, we would like to use KMP to built a complete POS solution, some of requirements is to be able to comunicate with hardware devices easily with TCP, UDP and Serial protocols, what would be the best practices to make such comunications via KMP? We should write native modules for that or we can use something that yet exist? Thank you.
i
@streetsofboston so the ktor websocket can be used to fire one time pure TCP socket requests?
s
I think so. This sounds to me like a plain TCP connection, but closing it when a response (good or bad) has been received. Create one outgoing socket to send the request frame, one incoming socket to listen to the response.
I'd try it out and see if this would work.
i
Yeap for TCP printers it must be just a plain TCP request, I'd give it a try too, then I will need to find something for UDP and Serial.
👍 1
d
In fact, inside Ktor, there is a library
ktor-network
that does TCP and UDP, that targets almost all platforms. Though, IIRC, TLS is only supported on JVM.
l
I implemented a generic network API on top of Unix sockets, it was absolutely trivial.
Calling native C API's from Kotlin native is very easy, and more pleasant than using plain C.
i
@Didier Villevalois isn't
ktor-network
a part of
ktor-server
so not compatible with KMP?
d
IIRC, it supports JVM (obviously), native, and nodeJS.
🙌 1
🙌🏾 4