Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8801155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:45:46+00:00 2026-06-14T00:45:46+00:00

I have a program that performs overlapped I/O on a serial port and I

  • 0

I have a program that performs overlapped I/O on a serial port and I am seeing cases where data that has been received is not being read by the application. My code is using SetCommMask() and WaitCommEvent() as follows:

if(!waiting_for_comm_event)
{
   comm_event_ready = false;
   if(!SetCommMask(port_handle, EV_RXCHAR | EV_ERR | EV_RLSD))
      throw OsException(my_strings[strid_set_comm_mask_failed].c_str());
   rcd = WaitCommEvent(port_handle, &event_mask, &event_control);
   last_error = GetLastError();
   if(rcd && event_mask != 0)
       comm_event_ready = true;
   else if(last_error != ERROR_IO_PENDING)
       throw OsException(my_strings[strid_wait_comm_event_failed].c_str());
   else
       waiting_for_comm_event = true;
  }

This code is invoked after I have written any data in my output buffer. There is a possibility that data could be received while this writing is taking place. Will WaitCommEvent() report the condition where there is already data waiting to be read?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:45:48+00:00Added an answer on June 14, 2026 at 12:45 am

    If you have to ask here, you don’t want to know the answer.

    No, really — it means you’re relying on undocumented behavior that could change in future Windows versions.

    You can instead use overlapped I/O to start tracking incoming data and events before you send the data that triggers them.

    Two approaches (I use a ReadFileEx variant of the first in my own serial code):

    • Issue a background (overlapped) read.
    • Issue a background (overlapped) WaitCommEvent.
    • Write the data.
    • Wait on both background operations… completion of either one will cause WaitForMultipleEvents to proceed.

    or

    • Issue a background (overlapped) WaitCommEvent.
    • Write the data.
    • Wait on the background operation.
    • If the wake event was receipt of data, read it.

    In either case, incoming data and errors, even before WriteFile completes, will be detected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that performs some network IO that compiles a 32 bit
I have a java program that performs 5 different tasks. When I run the
I have program that has a variable that should never change. However, somehow, it
I have a python program that performs several independent and time consuming processes. The
I have to write a program that performs highly computationally intensive calculations. The program
I have a project where I am required to fix this program that has
I'm working on a small server program that takes data received from the network
I have a program that performs a long-time computations, so I want to speed
We have a C# program that performs some timing measurements. Unfortunately, the first time
I'm building a program that performs some users tests and needs to record data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.