i am trying to write a very simple socket program, what i basically want is that the client keeps listening for communication from the server, in a while(true) loop. now i also want client to be able to send some data back to the server in the middle of it listening.
The only solution i can think of is making a thread for the read and write, and interrupting the read thread everytime i have to do a write.
is there a better solution or is this the only way i can do this