Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C Windows Win32 Visual-Studio , +
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 2:36am

1 solution

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

Solution 1

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

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

  Print Answers RSS
0 OriginalGriff 325
1 Sergey Alexandrovich Kryukov 289
2 CPallini 275
3 DamithSL 260
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 14 May 2013
Copyright © CodeProject, 1999-2014
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