Re: Protocols to exchange messages via a socket
- From: William Ahern <william@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 12 Mar 2007 14:00:30 -0700
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/
.
- Follow-Ups:
- Re: Protocols to exchange messages via a socket
- From: Rainer Weikusat
- Re: Protocols to exchange messages via a socket
- References:
- Protocols to exchange messages via a socket
- From: the_edge123 . nospam
- Protocols to exchange messages via a socket
- Prev by Date: Re: Protocols to exchange messages via a socket
- Next by Date: Re: accept blocking even when connections available
- Previous by thread: Re: Protocols to exchange messages via a socket
- Next by thread: Re: Protocols to exchange messages via a socket
- Index(es):
Relevant Pages
|
|