Board index » delphi » Indy TCP - Component (How to sen files)

Indy TCP - Component (How to sen files)

Hello.

How can I send mor then one file with the indy tcp-Client component, without
without dis - and reconnecting with the server each time? If I send more
files, the server puts all files together into one file. ( I use the command
Server.Readstream ) The Stream is a TFileStream.

Thankz

Holger

 

Re:Indy TCP - Component (How to sen files)


"hardrocker" <hardroc...@web.de> schrieb im Newsbeitrag
news:3b4a203c_2@dnews...
Quote
> Hello.

> How can I send mor then one file with the indy tcp-Client component,
without
> without dis - and reconnecting with the server each time? If I send more
> files, the server puts all files together into one file. ( I use the
command
> Server.Readstream ) The Stream is a TFileStream.

The solution is rather simple:
deigne you own protocol like:

WriteLn('FILE ' + filename);
writestream
WriteLn('FILE ' + filename);
writestream
WriteLn('FILE ' + filename);
writestream (and so on)
WriteLn('QUIT');

Re:Indy TCP - Component (How to sen files)


Quote
> How can I send mor then one file with the indy tcp-Client component,
without
> without dis - and reconnecting with the server each time? If I send more
> files, the server puts all files together into one file. ( I use the
command
> Server.Readstream ) The Stream is a TFileStream.

If you're using TIdTCPClient and TIdTCPServer, then you're designing the
protocol.  You need to provide some type of conversation tells the server
what to expect, like:

C: CONNECT
S: Welcome to My Custom File Service.
C: PUT MyDataFile.TXT 9234 octets
S: READY MyDataFile.TXT 9234 octets
C: (sends 9234 bytes)
S: DONE MyDataFile.TXT 9234 octets
C: PUT MyOtherDataFile.TXT 201284 octets
S: READY MyOtherDataFile.TXT 201284 octets
C: (sends 201284 bytes)
S: DONE MyOtherDataFile.TXT 201284 octets
C: QUIT
S: BYE

This will allow use of ReadStream without reading until the connection
closes.

Is there some reason you can't use a proven protocol like FTP?

Re:Indy TCP - Component (How to sen files)


Use a zip component to zip all the files and then send the zipped file as a
stream,
on the server unzip it.   It works extremely well and all your stuff gets
compressed.
I use VCLzip, it native vcl (no dlls) and is cheap 49 bucks with source and
it is rock solid.
If you want to spend more pick up a copy of Abbrevia from Turbo power.

If you can't use a zip solution, you just need to tell the read stream how
many bytes to read, save the file and then reset the stream for the next
file.

For my day job I created a replication system using Indy and VCL zip,
basicly I loop through each dir, zip all the files and then send each zipped
dir to the server.
I don't have the code here, but send me a private email and I will send you
a example.

Tony Caduto

Quote
"hardrocker" <hardroc...@web.de> wrote in message news:3b4a203c_2@dnews...
> Hello.

> How can I send mor then one file with the indy tcp-Client component,
without
> without dis - and reconnecting with the server each time? If I send more
> files, the server puts all files together into one file. ( I use the
command
> Server.Readstream ) The Stream is a TFileStream.

> Thankz

> Holger

Other Threads