views:

359

answers:

1

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"?

+1  A: 

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.

John Saunders