Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non blocking IO for Android

I'm currently trying to assess whether a project can be realised for Android. One major problem I see it that, since it's a P2P client, we'd have to keep a considerable amount of connections open when running. Now the connections do not transfer large amounts of data, it's more of a messaging system, so having a thread for each connection creates a useless overhead if we're reading a single message of 64 bytes every now and then.

So I was wondering whether there is support for non blocking IO such as select() or poll() on Linux.

Any suggestion?

like image 506
cdecker Avatar asked Nov 27 '10 19:11

cdecker


1 Answers

Check out java.nio Sockets, Selectors, and Channels. Some links:

Android: Unbuffered IO http://developer.android.com/reference/java/nio/channels/ServerSocketChannel.html http://developer.android.com/reference/java/nio/channels/SocketChannel.html http://www.developer.com/java/article.php/3837316/Non-Blocking-IO-Made-Possible-in-Java.htm

Or, maybe I didn't read your question right.

like image 134
mchang Avatar answered Oct 03 '22 07:10

mchang