Click here to Skip to main content
15,897,187 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Switch off Debug Assertions Pin
Erudite_Eric17-Jun-12 20:38
Erudite_Eric17-Jun-12 20:38 
AnswerRe: Switch off Debug Assertions Pin
AmbiguousName18-Jun-12 0:23
AmbiguousName18-Jun-12 0:23 
AnswerRe: Switch off Debug Assertions Pin
David Crow18-Jun-12 8:18
David Crow18-Jun-12 8:18 
AnswerRe: Switch off Debug Assertions Pin
jkirkerx18-Jun-12 10:37
professionaljkirkerx18-Jun-12 10:37 
QuestionRunning Ping on CWinThread::Onidle Pin
ForNow16-Jun-12 16:12
ForNow16-Jun-12 16:12 
AnswerRe: Running Ping on CWinThread::Onidle Pin
«_Superman_»16-Jun-12 17:29
professional«_Superman_»16-Jun-12 17:29 
GeneralRe: Running Ping on CWinThread::Onidle Pin
ForNow16-Jun-12 19:02
ForNow16-Jun-12 19:02 
AnswerRe: Running Ping on CWinThread::Onidle Pin
SoMad16-Jun-12 18:38
professionalSoMad16-Jun-12 18:38 
No, do not use Ping and do not rely on running it in OnIdle(), you should use a timer.

There are several ways a TCP link can "break" without both sides being properly notified, especially over the Internet, but even on a LAN. If it is important to you to have reliable, persistent links and you have control over the server side code, I suggest you define a keep-alive mechanism.

There are many, many ways of doing this. Over the years I have found the following approach to be sufficient just about anywhere I use persistent TCP connections.
- Determine which side will be sending data the most. Let's call that side A, the other side is side B. Depending on the nature of your applications, side A can be either the server or the client.
- Determine the maximum time a link can be down before reacting to it - 1 second, 10 seconds, 30 seconds, etc. Let's call that T. You do not want to flood the network with these messages, so go as high as you can.

While connected:
- Side A must keep track of the last time a message (data or keep-alive) was sent. If more than T/3 seconds have passed since a message was sent, send a keep-alive message. If the link has gone down, the socket send operation will fail and the program has to react to it.
- Side B must keep track of the last time a message (data or keep-alive) was received. If more than T seconds have passed since a message was received, consider the link down and react to it.


Soren Madsen
GeneralRe: Running Ping on CWinThread::Onidle Pin
ForNow16-Jun-12 19:02
ForNow16-Jun-12 19:02 
Questionoperator overloading Pin
Member 912994316-Jun-12 8:28
Member 912994316-Jun-12 8:28 
AnswerRe: operator overloading Pin
Chris Losinger16-Jun-12 8:48
professionalChris Losinger16-Jun-12 8:48 
AnswerRe: operator overloading Pin
Member 913892418-Jun-12 18:16
Member 913892418-Jun-12 18:16 
QuestionOnLButtonDblClk not working in CMainFrame Pin
_Flaviu15-Jun-12 23:34
_Flaviu15-Jun-12 23:34 
AnswerRe: OnLButtonDblClk not working in CMainFrame Pin
Richard MacCutchan16-Jun-12 0:12
mveRichard MacCutchan16-Jun-12 0:12 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
_Flaviu16-Jun-12 0:52
_Flaviu16-Jun-12 0:52 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
Richard MacCutchan16-Jun-12 0:58
mveRichard MacCutchan16-Jun-12 0:58 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
_Flaviu16-Jun-12 1:16
_Flaviu16-Jun-12 1:16 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
Richard MacCutchan16-Jun-12 1:23
mveRichard MacCutchan16-Jun-12 1:23 
AnswerRe: OnLButtonDblClk not working in CMainFrame Pin
«_Superman_»16-Jun-12 3:10
professional«_Superman_»16-Jun-12 3:10 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
_Flaviu16-Jun-12 4:13
_Flaviu16-Jun-12 4:13 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
«_Superman_»16-Jun-12 17:20
professional«_Superman_»16-Jun-12 17:20 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
_Flaviu17-Jun-12 9:00
_Flaviu17-Jun-12 9:00 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
_Flaviu17-Jun-12 19:38
_Flaviu17-Jun-12 19:38 
GeneralRe: OnLButtonDblClk not working in CMainFrame Pin
«_Superman_»17-Jun-12 19:46
professional«_Superman_»17-Jun-12 19:46 
AnswerRe: OnLButtonDblClk not working in CMainFrame Pin
Eugen Podsypalnikov17-Jun-12 20:28
Eugen Podsypalnikov17-Jun-12 20:28 

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.