Click here to Skip to main content
15,896,439 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionC++ Run Time Error "Stack around the variable 'Student' was corrupted." Pin
Umad Ahmad27-Jun-18 1:45
Umad Ahmad27-Jun-18 1:45 
AnswerRe: C++ Run Time Error "Stack around the variable 'Student' was corrupted." Pin
Richard MacCutchan27-Jun-18 2:36
mveRichard MacCutchan27-Jun-18 2:36 
QuestionConvert C++ code to python Pin
Megha Bhamare27-Jun-18 1:26
Megha Bhamare27-Jun-18 1:26 
AnswerRe: Convert C++ code to python Pin
Richard MacCutchan27-Jun-18 2:30
mveRichard MacCutchan27-Jun-18 2:30 
QuestionHow to call a 'C' program function from VB code ? Pin
Sakthiu26-Jun-18 3:31
Sakthiu26-Jun-18 3:31 
AnswerRe: How to call a 'C' program function from VB code ? Pin
Victor Nijegorodov26-Jun-18 4:04
Victor Nijegorodov26-Jun-18 4:04 
GeneralRe: How to call a 'C' program function from VB code ? Pin
Sakthiu26-Jun-18 4:08
Sakthiu26-Jun-18 4:08 
QuestionRe: How to call a 'C' program function from VB code ? Pin
David Crow26-Jun-18 4:38
David Crow26-Jun-18 4:38 
AnswerRe: How to call a 'C' program function from VB code ? Pin
Sakthiu26-Jun-18 4:44
Sakthiu26-Jun-18 4:44 
AnswerRe: How to call a 'C' program function from VB code ? Pin
David Crow26-Jun-18 4:49
David Crow26-Jun-18 4:49 
AnswerRe: How to call a 'C' program function from VB code ? Pin
Randor 26-Jun-18 5:44
professional Randor 26-Jun-18 5:44 
PraiseRe: How to call a 'C' program function from VB code ? Pin
«_Superman_»1-Jul-18 18:28
professional«_Superman_»1-Jul-18 18:28 
QuestionDIALOG WITH MULTIPLE THREADS Pin
Member 1142662425-Jun-18 7:52
Member 1142662425-Jun-18 7:52 
AnswerRe: DIALOG WITH MULTIPLE THREADS Pin
Randor 25-Jun-18 8:22
professional Randor 25-Jun-18 8:22 
AnswerRe: DIALOG WITH MULTIPLE THREADS Pin
Victor Nijegorodov25-Jun-18 8:52
Victor Nijegorodov25-Jun-18 8:52 
QuestionCan't automate Excel from Windows 10 Pin
garyflet21-Jun-18 8:39
garyflet21-Jun-18 8:39 
AnswerRe: Can't automate Excel from Windows 10 Pin
Victor Nijegorodov21-Jun-18 20:59
Victor Nijegorodov21-Jun-18 20:59 
AnswerRe: Can't automate Excel from Windows 10 Pin
_Flaviu21-Jun-18 22:43
_Flaviu21-Jun-18 22:43 
Questionlooking for 3rd party library to "create overlay guided user experiences" ? Pin
Maximilien21-Jun-18 8:17
Maximilien21-Jun-18 8:17 
QuestionTCP/IP Socket connectivity issue in Internet Pin
manoharbalu19-Jun-18 1:44
manoharbalu19-Jun-18 1:44 
AnswerRe: TCP/IP Socket connectivity issue in Internet Pin
Jochen Arndt19-Jun-18 2:52
professionalJochen Arndt19-Jun-18 2:52 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
manoharbalu19-Jun-18 3:44
manoharbalu19-Jun-18 3:44 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
Jochen Arndt19-Jun-18 4:33
professionalJochen Arndt19-Jun-18 4:33 
That is too much (unformatted) code to check.

Sending data timer driven is fine. But for receiving you should use an own thread that handles the receiving and supports timeouts. Using serializing might be not the best choice.

When not detecting timeouts and the connection is dropped, the read function will wait forever. Even after establishing a new connection, the pending wait will never finish because the new connection uses a different socket handle.

The typical flow of receiving in a worker thread (not using serialization):
C++
while (1)
{
    // Wait for events using WaitForMultipleObjects() here
    // Events: new data available and stop thread
    // Timeout: According to requirements; e.g. 10 seconds
    
    if (StopEvent)
        break;
    if (TimeOut)
    {
        // Try to reconnect here or break when main thread reconnects
    }
    if (ReceiveEvent)
    {
        // Receive data so that number of package bytes are contained (when not fixed size)
        // Receive complete package here if available
        // Otherwise read available date into buffer and use local variables to continue receiving
    }
    if (CompletePackageReceived)
    {
        // Process it here (deserialize)
        // Send response here
        // Process data here or pass them to main thread
    }
    if (CriticalError) // in any function called above
    {
        // Report error
        break;
    }
}
// Close connection here or in main thread
// Use the return value to indicate the reason why the thread has terminated
//  or pass the state to the main thread

GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
manoharbalu20-Jun-18 19:02
manoharbalu20-Jun-18 19:02 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
Jochen Arndt20-Jun-18 21:04
professionalJochen Arndt20-Jun-18 21:04 

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.