Re: Suggestions for custom application-layer protocol?
From: Glyn Davies (gryn_at_riffraff.plig.net)
Date: 05/27/05
- Next message: Glyn Davies: "Re: Suggestions for custom application-layer protocol?"
- Previous message: Paul Taylor: "Re: Need guidance !!"
- In reply to: Walter Roberson: "Re: Suggestions for custom application-layer protocol?"
- Next in thread: Tom Anderson: "Re: Suggestions for custom application-layer protocol?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 27 May 2005 10:52:20 +0000 (UTC)
In comp.os.linux.embedded Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote:
> In article <d7407b$2e4$1@magenta.plig.net>,
> Glyn Davies <gryn@riffraff.plig.net> wrote:
> :For simplicity of implementation, I'd recommend implementing a message
> :layer over the TCP socket - something as simple as a two byte binary header
> :to indicate the length of the message to follow.
> :This means you can then read a whole message - text based or otherwise,
> :and the process it accordingly. You don't need to mess about with parsing
> :lines and stuff like that.
> You still need to "mess about" if your data might not fit in a single
> packet. Recall that when you read() from a socket you are not certain
> to get all of the data unless the data length is no greater than
> your system's atomicity limits [PIPE_BUF]. The POSIX minimum
> value for PIPE_BUF is 512 -- so in the general case a write() of
> more than 512 bytes may require multiple read() statements.
Yes - but you do know how much you are getting.
You can handle all this stuff in a comms layer, then concentrate on your
application logic.
I've done countless systems using this technique. Works well, and is simple.
Glyn
-- ------------------------------------------------------------------------ Glyn Davies / gryn@plig.net / www.technobobbins.com / Insert quote here? ------------------------------------------------------------------------
- Next message: Glyn Davies: "Re: Suggestions for custom application-layer protocol?"
- Previous message: Paul Taylor: "Re: Need guidance !!"
- In reply to: Walter Roberson: "Re: Suggestions for custom application-layer protocol?"
- Next in thread: Tom Anderson: "Re: Suggestions for custom application-layer protocol?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|