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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:06:01+00:00 2026-06-17T19:06:01+00:00

I am developing an application with C++ and having some difficulty with boost sockets.

  • 0

I am developing an application with C++ and having some difficulty with boost sockets. The server sends an image but not all the bytes are received by the client; the client always receives about 500 bytes less than the server sent. Provided below is the pertinent code and screenshots of the program running.

Server code:

int sent = boost::asio::write(*socket, response, boost::asio::transfer_all(), error);
std::cout << "Sent: " << sent << std ::endl;

Client code (I know that read_some will block if the total bytes sent by the server is divisible by 10000; this code is just for testing):

int len = 0;
int count = 0;
do {
    len = socket->read_some( boost::asio::buffer( imageData, 10000 ) ); 
    count += len;
    std::cout << "len: " << len << std::endl;
    std::cout << "count: " << count << std::endl;
} while(len == 10000);

std::cout << "Image Received of size: " << count << std::endl;

Screenshot of server:
Screenshot of server

Screenshot of client:
Screenshot of client

Thanks for your time; any help or suggestions would be greatly appreciated.

  • 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-17T19:06:02+00:00Added an answer on June 17, 2026 at 7:06 pm

    There’re no guarantee you’ll receive complete buffers of 10000 bytes.

    I’d recommend following approach:

    To send some binary data w/o any explicit terminator, first send its size and only then data itself. In this case client will know how many data in this chunk it should receive.

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

Sidebar

Related Questions

I'm developing a Vaadin application and am having extreme difficulty getting some aspects of
I am developing an ASP.Net MVC 3 Web application and I am having some
I am developing application which is having Gujarati font in text-view but my problem
I am having some issues developing an application with require.js. Whenever I edit a
I am currently developing a WebGL-based application, and I am having some trouble with
I am developing an iphone application but I do not have an iphone. But
I'm developing a Flex application and am having some trouble working with asynchronous calls.
I'm developing an web application using Flex and JSP. I am having some performance
We are developing an iPad application with jquery mobile 1.0a4.1.js. We are having some
I am developing window application in that I am having 2 child windows on

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.