Click here to Skip to main content
15,908,834 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Memory Problem on CPtrArray Pin
Nobitact25-Mar-05 15:17
Nobitact25-Mar-05 15:17 
GeneralRe: Memory Problem on CPtrArray Pin
Blake Miller28-Mar-05 4:05
Blake Miller28-Mar-05 4:05 
QuestionHow to write a Winsock application that captures localhost process packets Pin
covansys200024-Mar-05 23:13
covansys200024-Mar-05 23:13 
General.:: Bluetooth programming ::. (i need help) Pin
wise_8224-Mar-05 23:04
wise_8224-Mar-05 23:04 
GeneralRe: .:: Bluetooth programming ::. (i need help) Pin
toxcct25-Mar-05 1:09
toxcct25-Mar-05 1:09 
GeneralRe: .:: Bluetooth programming ::. (i need help) Pin
wise_8225-Mar-05 11:25
wise_8225-Mar-05 11:25 
GeneralRe: .:: Bluetooth programming ::. (i need help) Pin
toxcct26-Mar-05 4:36
toxcct26-Mar-05 4:36 
QuestionHow to avoid using multiple threads in winsock programming? Pin
johtib24-Mar-05 22:53
johtib24-Mar-05 22:53 
I was hoping that I could get some tips on how I could structure a (piece of a) program that does the following:

* Listens for incoming UDP broadcasts (using recvfrom) on port 1337.
* Send periodic UDP broadcasts (every 5-60 seconds or so).
* Maintains a table of IP addresses of recently received broadcasts and periodically checking if no broadcasts have been received from a particular address in, say, 5 minutes.
     Address    | Last received
--------------------------------
    192.168.0.1 |   12:43:11
  192.168.0.101 |   09:11:27
 193.129.163.12 |   23:23:07


One way of doing it would be using three separate threads (pseudocode):

thread T1 {
  loop {
    Listen for broadcast
    Add to/update table
  }
}

thread T2 {
  loop {
    Send broadcast
    Sleep for 30 seconds
  }
}

thread T3 {
  loop {
    Check timestamps in table
    Take appropriate action if a timestamp is too old
    Sleep for 2 minutes
  }
}


This will work but involves more threads than I feel is needed (unnecesary risk of sync problems etc.) since none of the actions really need to be interleaved. Any suggestions?

Johan Tibell
AnswerRe: How to avoid using multiple threads in winsock programming? Pin
geo_m25-Mar-05 2:26
geo_m25-Mar-05 2:26 
AnswerRe: How to avoid using multiple threads in winsock programming? Pin
RobJones25-Mar-05 6:30
RobJones25-Mar-05 6:30 
GeneralRe: How to avoid using multiple threads in winsock programming? Pin
johtib25-Mar-05 8:10
johtib25-Mar-05 8:10 
GeneralRe: How to avoid using multiple threads in winsock programming? Pin
Blake Miller28-Mar-05 4:08
Blake Miller28-Mar-05 4:08 
GeneralRe: How to avoid using multiple threads in winsock programming? Pin
johtib4-Apr-05 23:23
johtib4-Apr-05 23:23 
GeneralRe: How to avoid using multiple threads in winsock programming? Pin
Blake Miller6-Apr-05 5:09
Blake Miller6-Apr-05 5:09 
GeneralRe: How to avoid using multiple threads in winsock programming? Pin
johtib8-Apr-05 21:46
johtib8-Apr-05 21:46 
GeneralRe: How to avoid using multiple threads in winsock programming? Pin
Blake Miller11-Apr-05 5:20
Blake Miller11-Apr-05 5:20 
GeneralRe: How to avoid using multiple threads in winsock programming? Pin
johtib11-Apr-05 6:39
johtib11-Apr-05 6:39 
GeneralRe: How to avoid using multiple threads in winsock programming? Pin
Blake Miller11-Apr-05 12:29
Blake Miller11-Apr-05 12:29 
Questiondraw on ToolBar Button??? Pin
Anything.J24-Mar-05 22:01
Anything.J24-Mar-05 22:01 
QuestionHow many of you use _tcsinc ? Pin
Chintoo72324-Mar-05 20:55
Chintoo72324-Mar-05 20:55 
AnswerRe: How many of you use _tcsinc ? Pin
toxcct24-Mar-05 21:17
toxcct24-Mar-05 21:17 
GeneralRe: How many of you use _tcsinc ? Pin
Chintoo72324-Mar-05 22:07
Chintoo72324-Mar-05 22:07 
GeneralRe: How many of you use _tcsinc ? Pin
toxcct24-Mar-05 22:16
toxcct24-Mar-05 22:16 
AnswerRe: How many of you use _tcsinc ? Pin
PJ Arends24-Mar-05 22:08
professionalPJ Arends24-Mar-05 22:08 
GeneralRe: How many of you use _tcsinc ? Pin
Chintoo72325-Mar-05 1:05
Chintoo72325-Mar-05 1:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.