Whether to divide the streams implementation of TCP client?

0 like 0 dislike
3 views
Previously worked as C++ & Qt, there is the case was different, perhaps even easier.

Now the challenge is to write a TcpClient for Android that is Java. So, naturally you need to process requests from the server, and to be able to take. So far, I settled on the idea is to divide the client into two streams, one for instance accepts requests from the server and processes them. The second thread that actually have a GUI and send requests.

What do you say? Is it possible to elect a better way? I want to listen to people working in this area, maybe someone can recommend a good link to the example code, unfortunately I have yet to find in the Internet the src which would have helped me.
by | 3 views

2 Answers

0 like 0 dislike
You are doing everything right. GUI in the vast majority of cases are decided in a single thread. In addition used an arbitrary number of threads for background tasks, reception of packets (including tcp), sending requests, etc.
\r
Offhand — after receiving each packet the twitch listener, which updates the UI.
There will be time — will look for something specific.
by
0 like 0 dislike
And you can't use select?
And the interface is transferred to the second thread, in the end the interface will not impede the work of TcpClient
by

Related questions

0 like 0 dislike
1 answer
asked Sep 2, 2019 by Don_Diego
0 like 0 dislike
1 answer
asked Aug 2, 2019 by Don_Diego
0 like 0 dislike
1 answer
asked Jul 1, 2019 by Don_Diego
0 like 0 dislike
1 answer
asked Jul 9, 2019 by Don_Diego
0 like 0 dislike
1 answer
asked Jul 15, 2019 by Don_Diego
110,608 questions
257,186 answers
0 comments
32,906 users