Link to home
Create AccountLog in
Avatar of butterhook
butterhookFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Sending data over sockets

Hello experts,

When sending data from server to client or vice versa, what is the best way to notify the other of the 'nature' of the data? In otherwords, consider the following scenario:

Client sends files to server for processing. It also needs to send periodic status requests whereby the server sends back its progress with a particular file, i.e. how much of it it has processed.

In this scenario, what's the best way for the client to say: "The data I am about to Send() is a file", or "The data I am about to send is a progress request"?

I have considered using the first byte of the message as a notify byte, e.g. 1 = I am sending a file, 2 = I am sending a status request, etc...

The only other way I can think of is using two sockets, one for file transfers and one for status requests. I was just wondering what was the best way of carrying out such a task.
ASKER CERTIFIED SOLUTION
Avatar of xersoft
xersoft

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of xersoft
xersoft

I would like to point out that in my above idea you would need to create a DLL holding the command classes that can be shared by both the client and the server. This may or may not be possible for you.
Avatar of butterhook

ASKER

Thank you. Your command class framework seems like an excellent way to go about it, and also answers another question I had about how to nicely encapsulate message formation and extraction instead of using the System.BitCoverter class all the time.