Hello,
Although I haven't tested this, I think you could achieve this by creating 3 methods server-side. Methods: StartSending, Send and StopSending
Client side: First call the StartSending method to notify the server you're about to start sending bytes. You could also provide a GUID and a file name, so you can use this procedure from 2 clients or more at the same time. The servershouldcreate a BinaryWriter
Then (back client side) you would use a BinaryReader to read chunks of bytes (e.g. you could read them per 1024 bytes) Put these bytes in a byte array After every 1024 bytes send them using the Send method (pass the byte array as argument).
When the end of the file has been reached, use Send one last time to send the remaining bytes Close the BinaryReader
Finally, call the StopSending to notify the server to finish its file. (Server can then close its BinaryWriter)
The method singatures could look something like this:
StartSending(Guid guid, string filename); Send(Guid guid, byte[] bytes); StopSending(Guid guid);
As I already mentioned, I haven't tested this, but I think it should work.
Kind regards, Stefan Adriaenssen |