I have a single server multiple client udp application. There is a single thread (thread#1) with a single socket (socket#1) to receive data from client#1 continuously. The task of this receiving thread is to continuously receive data at its socket.
I have a button which says "Send data to Client#1" on Server application GUI. When this button is pressed, I want my receiveing thread to suspend reception and send some data on socket#1 and when data is sent, continuous reception is resumed.
How can this be done? If I even postthreadmessage() when button is presses, the receiving thread has no check for these posted messages since it is always inside the while loop receiving messages. How can it check for posted message corresponding to buttons pressed?
EDIT: Another Suggestion
What if I make my socket "Event Driven"? i.e. whenever there is some data available at socket to be read, FD_READ event is generated and I can read on socket, and whenever I want to write some data on the socket, I GENERATE AN EVENT FD_WanttoWrite and then data is written on the socket. Is something similar to this possible?
(I know about FD_READ but I am not sure about FD_WanttoWrite when I wish to write something on Socket)