Recent

Author Topic: How do you stream a whole file directly to another machine?  (Read 2443 times)

Awesome Programmer

  • Sr. Member
  • ****
  • Posts: 451
  • Programming is FUN only when it works :)
    • Cool Technology
How do you stream a whole file directly to another machine?
« on: April 25, 2017, 02:40:33 pm »
I know you can read the file a CHUNK at a time and send it over the network, but what I want to know is if you can just stream the whole file.

Like

Code: Pascal  [Select][+][-]
  1. fs:TfileStream;
  2. fs := TFileStream.Create('Myfile.txt',fmOpenRead);
  3. fs.sendstreamt(aSocket);
  4.  

something like that.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • Lebeau Software
Re: How do you stream a whole file directly to another machine?
« Reply #1 on: April 25, 2017, 08:53:26 pm »
I know you can read the file a CHUNK at a time and send it over the network, but what I want to know is if you can just stream the whole file.

That is entirely dependent on the capabilities of the socket library you are using.  If it has an API for sending an entire file/TStream for you, then feel free to use it (it will likely just chunk the data automatically for you).  Otherwise, you have to chunk the data manually, like you are already doing.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: How do you stream a whole file directly to another machine?
« Reply #2 on: April 25, 2017, 10:07:16 pm »
on linux you can use senfile() syscall.... on windows you use. buffers or  transmitfile() of winsocks2 or you can implement memory maped io and send the hole memory of the file to the socket... your choice
« Last Edit: April 25, 2017, 10:09:19 pm by Blestan »
Speak postscript or die!
Translate to pdf and live!

 

TinyPortal © 2005-2018