Cloud Stack Ninja

I'm trying to open a NIO server socket channel as follows on Android (min API 21).

ServerSocketChannel.open().also {
    it.bind(InetSocketAddress(0))
}

But the above code gives me an error saying that - Call requires API level 24. In theory, I can use the ServerSocket and call it a day, but my client code is using SocketChannel, ByteBuffer etc. and mixing the two feels like a bad design!

Another thing that confuses me is that I can open() it at min API level 21 but can't bind() it at API level 21, then what purpose does it serve?



Read more here: https://stackoverflow.com/questions/64401671/why-does-serversocketchannelbind-require-api-level-24

Content Attribution

This content was originally published by Siddharth Kamaria at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: