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!
Read a buffer from the socket using
recv, and write it to the file usingfwrite. When you open the local file, before sure to use"wb"as the mode.Edit: Here’s a sketch of the general idea: