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

  • Home
  • SEARCH
  • 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 4122446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:28:57+00:00 2026-05-20T23:28:57+00:00

If this has been asked before in a different wording, I apologize. Heres my

  • 0

If this has been asked before in a different wording, I apologize.

Heres my issue. I have a Linux TCP server client relationship and in a certain part of my code, the server will write() chunks (lets say 512 bytes) of a file buffer to the client. I am wanting the client to reconstruct the file on the other side by somehow redirecting the buffer chunks outward to a already made file (mimicking a copy effect). I was considering a middle man whom would translate the buffer into characters and then use fprintf etc. to push the information to a file (this is the only way I can conceive how). However, this idea does not work when working with binary files as ascii would mess up the binary.

Is there a way to redirect a file buffer pointer into another file? Thanks!

  • 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-20T23:28:58+00:00Added an answer on May 20, 2026 at 11:28 pm

    Read a buffer from the socket using recv, and write it to the file using fwrite. When you open the local file, before sure to use "wb" as the mode.

    Edit: Here’s a sketch of the general idea:

    socket input = open_socket(server, server_port);   
    FILE *file = fopen("localfile.bin", "wb");
    char buffer[some_size];
    
    do { 
        size_t received = recv(input, some_size);
        fwrite(buffer, received, 1, file);
    } while (received != 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question has been asked before ( link ) but I have slightly different
This has been asked before (question no. 308581) , but that particular question and
I'm sure this has been asked before, but I can't find it. What are
It's quite possible a question like this has been asked before, but I can't
I know this question has been asked before, but I ran into a problem.
I know this specific question has been asked before , but I am not
I know this question has been asked a bit before. But looking around I
I'm sure this has already been asked and answered so I apologize in advance
I'm not sure if this has been asked or not yet, but how much
If this question has already been asked I appologies, please point me in the

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.