Hello,
TL;DR - Can I listen on a socket to check for when more data arrives from a server then set a variable to true to indicate that data has arrived?
Problem
I have a server and I need to code a client to access it and process data. The client currently receives data from the server using read(..). Every x amount of seconds (where x is a random number), the server will send new data to the client.
However, during this period of time where no data is being sent to the client, the client must be able to send data back to the server. After x seconds, the server will send new data, the client must stop accepting input from the user and the new data is printed. This bit has me stuck.
I plan on creating a thread (I must use pthread) to handle input from the user, then destroy the thread as soon as more data from the server arrives. Am I able to listen to a socket to check for when more data has arrived?
Thanks