I have c++ socket server and android client. Server constantly sends data to the client after a time interval. The question is how to implement this getting data on android client
socket = new Socket("xxx.xxx.xxx.x", xxxx); // I connect
.... socket.getInputStream(); // Get first input stream
How to make it continuously receiving data? I tried something like this while(true) { ..socket.getInputStream(); Thread.sleep(…); } It didn’t help
Note that you have to open the input stream only once. Then, if you perform a
read()operation on the input stream it will block (of course if you use a blocking read (blocking vs non-blocking read) ).You can find information about java socket programming here: link
You can find lost of examples for socket programming on Android platform here: link
For example: