我应该选择升压短耳或Aysnc套接字线程的Andr​​oid? [英] Should I choose Boost Asio or Aysnc Socket threads in Android?

查看:235
本文介绍了我应该选择升压短耳或Aysnc套接字线程的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发Android的基于网络的应用程序的用户界面的过程,将执行以下类型的功能的

I am in process of developing an network based UI app for Android which would perform following kind of functionalities


  1. 需要与N /运行W¯¯基于嵌入式设备(> 100在时间)的TCP服务器进行通信。

  2. 轮询这些设备定期为获取最新的信息

  3. 发送和从这些设备接收信息

  4. 所有上述信息将被应用程序的UI控制和管理

考虑到上述情况,该应用就可能要产生多个线程对多个连接和管理them.So我的查询是

Considering above situations, the app would probably have to spawn multiple thread's for multiple connections and managing them.So my query is


  1. 这是好方法来开发使用Boost.Asio的图书馆网络模块?或者是没关系高达插座线程100打开连接?

  1. 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?

如果使用Boost.Asio的,则网络模块将使用NDK,访问JNI会接触到的地方,这反过来又可能导致慢响应开发分开?

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!

提前非常感谢。

推荐答案

我建议采取看看新的I / O ,这是支持在Android上。使用它,你可以处理一个线程多个连接,该API在原理为Posix类似选择()电话。

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.

如果你决定去为你的第二个选项(网络在C / C ++实现的code)我不认为你应该担心的JNI性能。 Android版的API显著部分只是对C / C ++上方薄JNI包装反正。

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.

这篇关于我应该选择升压短耳或Aysnc套接字线程的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆