使用Android NDK(2.3及以上版本)开发网络库
Scenerio
-
第三方应用程序(基于TCP套接字)与我们的本机库通信 .
-
我们的库处理该数据,然后使用TCP套接字通信与服务器通信 . 通信是双向的 .
我们在第三方应用程序和我们的IPC库之间设计并实现了套接字通信机制 . 我们的库正在利用第三方应用程序端口(默认值:6700) Build 服务器之间的连接 .
因此,它是一种环回连接,通过它我们的库和第三方应用程序之间进行通信 .
int on = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
bind(s, (struct sockaddr *) &sin, sizeof (sin));
问题领域
Everything works fine, but due to it, the performance is downgraded. If network library is not present , the communication is very fast. To verify that issue lies in loopback tcp socket, we removed all internal processing of library. The library just acting as pseudo-server (pass-through) for the application. The app sends data to localhost and socket, and the library just forwards it to server as it is.
> Queries
那么有什么方法可以提高性能吗?
1)Android上的UNIX域套接字怎么样,它们可以在app和我们的库之间使用吗?
2)可以使用Binders在用户级应用程序和原生Android库之间进行通信吗?
3)或者我们是否有类似于IOCTL SIO_LOOPBACK_FASTPATH的东西(TCP环回快速路径由应用于发送和接收套接字的套接字IOCTL SIO_LOOPBACK_FASTPATH启用 . )Transmission Control Protocol (TCP) Loopback Optimization
提前谢谢了