L
L
lunat1k2011-02-05 00:50:48
Java
lunat1k, 2011-02-05 00:50:48

Is it worth threading the TCP client implementation?

Previously, C++ & Qt worked, things were different there, perhaps even simpler.

Now there is a task to write TcpClient for android, that is, in Java. So, naturally, you need to process requests from the server, and be able to receive it yourself. So far, I have settled on the idea that this is to divide the work of the client into two threads, one, for example, receives requests from the server and processes them. The second thread, actually gui itself and sending requests.

What do you think? Is it possible to choose a better path? I would like to listen to people who worked in this area, maybe someone can advise a good link to an example with code, unfortunately I have not yet found src on the Internet that would help me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
javenue, 2011-03-07
@lunat1k

You are doing everything right. GUI in the vast majority of cases is taken out in one thread. In addition, an arbitrary number of threads is used for background tasks, receiving packets (including tcp), sending requests, etc.
Offhand - after receiving each packet, listeners twitch, which update the UI.
When I have time, I'll look for something specific.

E
equand, 2011-02-05
@equand

And there it is impossible to use select?
And transfer the interface to the second thread, as a result, the interface will not slow down from the work of the tcpclient

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question