Board index » delphi » how to send binary data using a TClientSocket...

how to send binary data using a TClientSocket...

Hi everyone,

I'd like some advice on how to send binary data (files).
I thought of maybe using a filestream to get the data and then using a
TClientSocket to send it.
Can it be done that way? How?

Thanks for your attention sofar,

Vinz.

 

Re:how to send binary data using a TClientSocket...


Vincent,
  Check out the demo titled "Multi-threaded server application using
TServerSocket" available at
http://www.borland.com/devsupport/delphi/downloads/

You can write binary data to the socket stream just like a TFileStream or
a TMemoryStream. It makes things a lot easier if you send the number of
bytes that you're going to send first. If you are going to send a blob or
a binary file, count the bytes first then send those as a fixed length
string or binary "packet"

Look at how some of the RFC's specify protocols http://www.faqs.org/rfcs/
and try to draft up a small protocol for you and your colleagues to
follow.

Cheers,
  Gardner

Quote
Vincent Koopman wrote:
> Hi everyone,

> I'd like some advice on how to send binary data (files).
> I thought of maybe using a filestream to get the data and then using a
> TClientSocket to send it.
> Can it be done that way? How?

> Thanks for your attention sofar,

> Vinz.

Other Threads