Reputation: 1971
I Have a socket-based server and I want to send a file from that server to all the connected I tried using on the server side
tcpClient.Client.SendFile(filename)
But how can I distinguish this message on the client-part? Beacause the normal communication protocol that I use is based on XML, and by sending a txt file for example it won't get parsed. Is there a method to capture on the client side the files send using "SendFile"?
Upvotes: 1
Views: 2344
Reputation: 161773
If you're programming down at the socket level, then you need to create your own protocols.
For instance, you might decide that the client will send commands to the server, like "FILE file.typ\n". When the server sees this command, it expects to see the number of bytes in the file next, as "nnnnnn\n". Following that, it would expect the next "nnnnnn" bytes to be the contents of the file.
Upvotes: 1