Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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)
Posted

1 solution

You may use the main thread (or just another one) for writing data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900