0

I am developing an android application where it has to talk to multiple TCP based servers in run time. Now i am using java sockets to communicate and threads to handle multiple clients. But there is a requirement in application that we need to talk to more numbers of servers in run time. So i am using the concept of Java NIO with selectors to handle multiple servers at a time. But the problem now i am facing is that i am not able to communicate with any of the servers. So please any one suggest can i use selector at client side.

4

1 回答 1

1

您可以使用选择器,但它们会增加编码的复杂性。我建议你使用像 netty 或 mina 这样的库来为你管理这个。

另一种方法是使用阻塞 NIO,它更易于使用恕我直言并具有多个线程。在 PC 上,它可以处理多达 1000 个连接,而在 Android 设备上,它可以处理数十个左右。

于 2013-01-10T09:36:45.053 回答