Max Reommended buffer size to send using (nonblocking) WSASend

Posted on 2005-04-17
Last Modified: 2008-01-09
Hi ,

My server (C++ , MSVC6) using completion-port to send huge data-buffers
to the client .
till now, i was using a single call to WSASend() to send ALL the data
(single buffer , can be 10MB-100MB ) .

I noticed that if i'm using buffer-size to be ~60MB and above , the
WSASend returns error about the size .

my question is - what is the maximum buffer size that it's recommended
to send ?

As much as i understand, if i'm sending "big" buffers , the NDIS/TDI
(or other O.S component) can split them into smaller buffers so the
TCP/IP will send 8K each time , right ? so it's better to fill-up the
"lower-layer" with the maximum buffer size that it can handle .

In another words - most implementations send 8KB-16KB because this is
the "send buffer" size, but it means that the O.S will be waiting for
new buffers , maybe it's better to send 1MB just to prevent this "O.S
waiting" .

Am i right ? any ideas ?


Question by:odedf
    LVL 22

    Accepted Solution

    It is a good idea to buffer up data so you make fewer system calls, but there's a limit to this goodness.

    If you try to send more than a megabyte or so, the paybacks get smaller and smaller, and you end up tying up system heap with your data.  Meanwhile your program gets less responsive, as it's spending a lot of time inside the system call.

    I'd keep each write to a megabyte or less.


    Author Comment

    Pls close this thread.
    No answer was accepted.

    LVL 14

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
    I will leave the following recommendation for this question in the Cleanup topic area:

    Accept: grg99

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    EE Cleanup Volunteer

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
    Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now