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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:02:41+00:00 2026-06-12T16:02:41+00:00

I can send very large text files no problem. I try to send a

  • 0

I can send very large text files no problem. I try to send a jpg, etc and it wont work. The file is the correct size. I don’t know what I’m missing.. I check my read and write functions by writing the data before sending to a temp.foo file. I check it, and it handles anything.

I send it like this

for(vector< .... >::iterator it = v.begin(); it!=v.end(); ++it ){
    pair<...> p=*it;
    send(s,p.first,p.second,0);
}

Then the other program reads it

    for(i = 0; i < size; i+=max){
    b= 0;
    while (b== 0) {
        if ((b = recv(s, buf, max, 0)) == -1) {
            perror("recv");
            exit(1);
        }
}
    stringstream ss;
    ss << buf;
    char * out = (char*)malloc(b); 
    memcpy(out,buff,numbytes);// Perhaps my error is here?
}
// write function call here
  • 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-12T16:02:42+00:00Added an answer on June 12, 2026 at 4:02 pm

    Some general points about handling binary data:

    1. Make sure you open the input and output files in binary mode, such as with the ios::binary flag or the “rb” or “wb” format. The default is text mode, which will mangle end-of-line characters in a binary file.

    2. Binary files can have NUL bytes (\0), which means you can’t use string-handling functions that work on NUL-terminated strings. C strings are not NUL safe. For instance, this code won’t fill ss properly since it interprets buf as a NUL-terminated string:

      stringstream ss;
      ss << buf;
      

    Also, on the line you point out, is buff with two fs a typo? On the other lines you reference buf with one f.

    memcpy(out,buff,numbytes);// Perhaps my error is here?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send some very large files (>200MB) through an Http output
I have a program that can send text to any other program for further
I am hoping someone can help me (once again). I have a very large
I need to pre-compress some very large html/xml/json files (large data dumps) using either
In my web application I am working with files. Some files are very large.
I just started using resque to do some processing on some very large files
My company created an application that can send large attachements from one mail recipient
I can send requests to friends using Multi Friend Request Selector inside my Page
I know that soap can send XML over http, is there any way to
How this UIButton rewind can send notification to UIButton play to perform playpauseaction method

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.