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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:49:47+00:00 2026-05-15T08:49:47+00:00

I think I’m in a problem. I have two TCP apps connected to each

  • 0

I think I’m in a problem. I have two TCP apps connected to each other which use winsock I/O completion ports to send/receive data (non-blocking sockets).

Everything works just fine until there’s a data transfer burst. The sender starts sending incorrect/malformed data.

I allocate the buffers I’m sending on the stack, and if I understand correctly, that’s a wrong to do, because these buffers should remain as I sent them until I get the “write complete” notification from IOCP.

Take this for example:

void some_function()
{
    char cBuff[1024];

    // filling cBuff with some data

    WSASend(...); // sending cBuff, non-blocking mode

    // filling cBuff with other data

    WSASend(...); // again, sending cBuff

    // ..... and so forth!
}

If I understand correctly, each of these WSASend() calls should have its own unique buffer, and that buffer can be reused only when the send completes.
Correct?

Now, what strategies can I implement in order to maintain a big sack of such buffers, how should I handle them, how can I avoid performance penalty, etc’?
And, if I am to use buffers that means I should copy the data to be sent from the source buffer to the temporary one, thus, I’d set SO_SNDBUF on each socket to zero, so the system will not re-copy what I already copied. Are you with me? Please let me know if I wasn’t clear.

  • 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-15T08:49:48+00:00Added an answer on May 15, 2026 at 8:49 am

    Take a serious look at boost::asio. Asynchronous IO is its specialty (just as the name suggests.) It’s pretty mature library by now being in Boost since 1.35. Many people use it in production for very intensive networking. There’s a wealth of examples in the documentation.

    One thing for sure – it take working with buffers very seriously.

    Edit:

    Basic idea to handling bursts of input is queuing.

    • Create, say, three linked lists of pre-allocated buffers – one is for free buffers, one for to-be-processed (received) data, one for to-be-sent data.
    • Every time you need to send something – take a buffer off the free list (allocate a new one if free list is empty), fill with data, put it onto to-be-sent list.
    • Every time you need to receive something – take a buffer off the free list as above, give it to IO receive routine.
    • Periodically take buffers off to-be-sent queue, hand them off to send routine.
    • On send completion (inline or asynchronous) – put them back onto free list.
    • On receive completion – put buffer onto to-be-processed list.
    • Have your “business” routine take buffers off to-be-processed list.

    The bursts will then fill that input queue until you are able to process them. You might want to limit the queue size to avoid blowing through all the memory.

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

Sidebar

Related Questions

Think about the games like Spiral Knights and Minecraft(Which I believe both use LWJGL)
Think about a rectangular div, which is split into 2 parts, each part is
Think Design: I have many applications that share the same user database! Other tables
Think I have an integer array like this: a[0]=60; a[1]=321; a[2]=5; now I want
Think my problem is I am trying to sum a count in the same
I think I've figured out the problem. I'm using a IP webcam stream, doing
I think I have a basic understanding of this, but am hoping that someone
I think this could be a very easy question for you. But I have
I think I have found a bug when setting or getting the Me.Top property
I think firefox's support to box model in CSS3 is soooooooooooooo poor... I have

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.