Click here to Skip to main content
15,881,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
manoharbalu21-Jun-18 0:55
manoharbalu21-Jun-18 0:55 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
Jochen Arndt21-Jun-18 1:31
professionalJochen Arndt21-Jun-18 1:31 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
manoharbalu21-Jun-18 19:36
manoharbalu21-Jun-18 19:36 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
Victor Nijegorodov21-Jun-18 20:35
Victor Nijegorodov21-Jun-18 20:35 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
Jochen Arndt21-Jun-18 20:55
professionalJochen Arndt21-Jun-18 20:55 
GeneralRe: TCP/IP Socket connectivity issue in Internet Pin
manoharbalu25-Jun-18 19:04
manoharbalu25-Jun-18 19:04 
AnswerRe: TCP/IP Socket connectivity issue in Internet Pin
jschell23-Jun-18 4:52
jschell23-Jun-18 4:52 
Questioninstalled apps Pin
john563217-Jun-18 20:22
john563217-Jun-18 20:22 
AnswerRe: installed apps Pin
Victor Nijegorodov17-Jun-18 20:45
Victor Nijegorodov17-Jun-18 20:45 
GeneralRe: installed apps Pin
john563217-Jun-18 20:53
john563217-Jun-18 20:53 
AnswerRe: installed apps Pin
User 742933817-Jun-18 21:33
professionalUser 742933817-Jun-18 21:33 
GeneralRe: installed apps Pin
john563217-Jun-18 22:58
john563217-Jun-18 22:58 
AnswerRe: installed apps Pin
User 742933817-Jun-18 23:04
professionalUser 742933817-Jun-18 23:04 
QuestionChange Tabs in Ribbon Control dynamically - C++ Pin
Gopi Nath14-Jun-18 2:13
Gopi Nath14-Jun-18 2:13 
AnswerRe: Change Tabs in Ribbon Control dynamically - C++ Pin
User 742933817-Jun-18 23:37
professionalUser 742933817-Jun-18 23:37 

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.