Re: Protocols to exchange messages via a socket



On Mon, 12 Mar 2007 03:20:32 -0700, the_edge123.nospam wrote:

Hello,

I'm not sure I'm at the right group for this question.
I want to send a binary message over a socket and I'm wondering which
protocols are best suitable:

1) <separator><msg in hexa printable characters><separator>
This solution works but doubles the message length :-(

2) <msg length><raw msg>
The issue is that we're not sure to be at the beginning of the msg.
Can I receive correctly the next message if I close and re-open the
socket in case of a decoding error ?


If all you're doing is writing messages across the wire, then no.
You cannot be sure how many messages were lost on the wire behind any
corrupted messages, but which were assumed "sent" by the sender. Also,
assuming TCP the atomicity of writes isn't guaranteed. You could have lost
1/2 a packet in transit.

You have to implement some sort of message accounting, for example
using windows and some retry protocol. To get an idea of how to approach
things (aside from reading the TCP RFC's), read up on this implementation:

http://airhook.ofb.net/
.



Relevant Pages

  • Re: Protocols to exchange messages via a socket
    ... protocols are best suitable: ... socket in case of a decoding error? ... You cannot be sure how many messages were lost on the wire behind any ... Since TCP ordinarily provides reliable, ...
    (comp.unix.programmer)
  • Re: Protocols to exchange messages via a socket
    ... socket in case of a decoding error? ... You cannot be sure how many messages were lost on the wire behind any ... assuming TCP the atomicity of writes isn't guaranteed. ... no message can ever be 'lost in transit'. ...
    (comp.unix.programmer)
  • Re: Protocols to exchange messages via a socket
    ... socket in case of a decoding error? ... You cannot be sure how many messages were lost on the wire behind any ... Since TCP ordinarily provides reliable, ... the reliability of the CRC16 checksum in TCP? ...
    (comp.unix.programmer)
  • Re: Protocols to exchange messages via a socket
    ... socket in case of a decoding error? ... You cannot be sure how many messages were lost on the wire behind any ... no message can ever be 'lost in transit'. ... It's a pretty weak guarantee, given all the horrifying network routers and ...
    (comp.unix.programmer)
  • Re: REMINDER: Re: HEADS UP: network stack and socket hackery over the next few weeks (fwd)
    ... committed an extensive set of socket and netinet changes which will likely render the network stack broken. ... Protocols can now explicitly request that a socket not be freed on last ... consumer reference, using the SS_PROTOREF flag, in order that they can ...
    (freebsd-net)