Right, so you need to develop a protocol which supports what you want to do.
For example, the http protocol sends the text string "Content-length" so that clients know the amount of data to expect, and strings such as "Content-Disposition: attachment; filename='filename.ext'". So the client knows a default filename before asking the user if they wish to rename it.
Once you had sent the data for all files, you can begin data transfer of the files. Its a good idea to use a synchronisation (expected sequence of bytes) so the client knows they have received each file correctly.
Bookmarks