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 5928753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:19:45+00:00 2026-05-22T14:19:45+00:00

I’m using asynchronous I/O because it does not block the calling thread and does

  • 0

I’m using asynchronous I/O because it does not block the calling thread and does the threading stuff behind the scenes. If I invoke multiple async operations like BeginWrite()’s on the same Stream, should I need to worry about that data buffer contents are mixed together?

Let’s assume I want to send 3 buffers:

Buffer1: 1111111111
Buffer2: 2222222222
Buffer3: 3333333333

I don’t mind if the buffers are sent in incorrect order, so

333333333311111111112222222222

is ok, but is it possible that buffer contents are got completely mixed together?

122213121212122333313111223333

PS: I’m 100% sure that someone already asked this in some form…

  • 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-05-22T14:19:46+00:00Added an answer on May 22, 2026 at 2:19 pm

    It depends on the implementation of the Stream. For instance sockets support multiple overlapped requests both for read and for write, and so does the file API. They guarantee consistency of each operation (no interleaving content) and also order of operations: for instance for socket reads the bytes received will be placed in the buffers posted in the order posted. If these guarantees would not be provided it would impossible to write high performance network application, as overlapping Sends are desired but overlapping Receives are actually required for high performance network IO. This behavior is described in many articles, including good ole’ Windows Sockets 2.0: Write Scalable Winsock Apps Using Completion Ports and is documented on MSDN Overlapped Input/Output:

    Both send and receive operations can
    be overlapped. The receive functions
    may be invoked multiple times to post
    receive buffers in preparation for
    incoming data, and the send functions
    may be invoked multiple times to queue
    up multiple buffers to be sent. Note
    that while a series of overlapped send
    buffers will be sent in the order
    supplied, the corresponding completion
    indications may occur in a different
    order. Likewise, on the receiving
    side, buffers will be filled in the
    order they are supplied, but
    completion indications may occur in a
    different order.

    Not surprisingly, the same guarantees carry over to the managed side of the world, eg. the NetworkStream class:

    Read and write operations can be
    performed simultaneously on an
    instance of the NetworkStream class
    without the need for synchronization.
    As long as there is one unique thread
    for the write operations and one
    unique thread for the read operations,
    there will be no cross-interference
    between read and write threads and no
    synchronization is required.

    That being said, throwing randomly async reads and writes on a Stream will result in chaos pretty quickly. Applications need to carefully orchestrate the order in which threads submit the operations so that the order is deterministic. Usually this means keeping accounting in a (synchronized) list with special care to do the async operation invocation while holding the synchronization lock.

    One final note is that all these async APIs make a special note in calling out that the order of completion is not guaranteed to match the order of submission.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT

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.