Click here to Skip to main content
13,090,178 members (52,106 online)
Rate this:
Please Sign up or sign in to vote.
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 14-May-13 1:36am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 14 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100