In article , Mark wrote: :I need to implement a simple application layer protocol that will be used to :communicate between an embedded device (single-board computer running Linux) :and a monitoring terminal (running Windows). There isn't alot of data being :passed around, mostly status information collected by the embedded device, :and control messages from the monitoring terminal. Messages will consist of :between 1 and 10 fields of data.
:I want the protocol to be text based rather than binary since the data :throughput is low.
OK.
:I also want the protocol to be based on TCP/IP.
For the purposes you describe, it sounds as if UDP might be a better fit. UDP has a lot fewer states to worry about. The main question, though, would be how you want either end to react if it notices that a packet has gone missing.
:Does :anyone here have any suggestions on the design of a simple protocol? Are :there simple, standard ways of formatting text messages to be sent over a :TCP socket (such as comma-separated)?
If the fields are consistant (e.g., if there are 3 fields then the first 2 are exactly the same as if there were only 2 fields, or if there are 3 fields they are always the -same- 3 fields) then you can just list the values with some convenient delimeter character.
If the fields are not consistant (including, e.g., only transfering data that changed) then keyword/value pairs would be typical. TEMP3=46 STATE=stable
The protocol doesn't start to get interesting until you have "fields" which are lists of values, or some fields may contain arbitrary text (including your standard delimeter character.) If it's less complex than that, just go ahead and do whatever seems natural.
:Since either the embedded device or the monitoring :terminal can initiate a message, is it preferable to have TCP servers :running on both sides? Or is it better to simply leave a TCP connection :open between client and server?
Sounds like UDP. If you use TCP servers on both sides, then -every- message requires the full 3-way negotiation. If you leave the TCP connection open, you have to worry about the possibility of the connection dropping and needing to detect and recover from that. [e.g., suppose you have to reboot the Windows machine.]