Issue
I am in process of developing an network based UI app for Android which would perform following kind of functionalities
- Needs to communicate with TCP servers running on n/w based embedded devices (>100 at a time).
- Polling these devices at regular intervals for fetching updated information
- Sending and receiving information from those devices
- All above information would be controlled and managed by application's UI
Considering above situations, the app would probably have to spawn multiple thread's for multiple connections and managing them.So my query is
Is it good approach to develop the network module using Boost.Asio libraries ? Or it is okay to open upto 100 of socket threads for connectivity?
If Boost.Asio is used, then network module would be developed seperately using NDK, to access JNI would come into place, which in turn could lead to slow response?
Alternatively, can there be other better options? Looking forward for your inputs!
Many thanks in advance.
Solution
I suggest taking a look at New I/O, which is supported on Android. Using it you can handle multiple connections in a single thread, the API is similar in principle to Posix select()
call.
If you decide to go for your second option (networking code implemented in C/C++) I don't think you should be worried about JNI performance. Significant part of Android APIs is just a thin JNI wrapper on top of C/C++ anyway.
Answered By - Code Painters
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.