Message Framing, Part 5

Past entries that you should have read by now:

With the preamble exchange out of the way, it is now time to
send some data. As before, we’re going
to get slightly different exchanges depending on the mode in which the framing
protocol is being used.

You may recall from Part 2 that one of the modes for TCP
connections was a request-reply mode used for streamed TCP connections. Request-reply streaming allows a single
message to be exchanged on the framed connection.

After the preamble is completed, the initiator of the
connection sends an unsized envelope record to exchange a message. An unsized envelope record starts with the
byte 5 followed by one or more data chunks and followed by a terminating byte
0. This chunking approach is very
similar to the way data is transferred using HTTP chunking. Each chunk consists of a non-zero size
followed by a payload that contains the size’s worth of octets. The size is encoded in the usual way. Finally, the receiver might send choose to
send an unsized envelope record back in response.

The other mode for TCP connections in Part 2 was a duplex
mode used for buffered TCP connections.
Buffered duplex allows many messages to be exchanged in either direction
between the two parties.

After the preamble is completed, the endpoints exchange
sized envelope records. A sized envelope
record starts with the byte 6 followed by a non-zero size and followed by the
size’s worth of octets. You might think
of this as an HTTP message that specifies the content length instead of using a
chunked encoding. The same variable
sizing is used as always.

Regardless of the transfer mode used for the message, the framing
connection is closed in the end by sending an end record. An end record is the byte 7. As we’ll see later though, closing the
framing connection doesn’t necessarily mean freeing the network resources.

Comments (1)

  1. Architecture Presentation: REST: A Pragmatic Introduction to the Web’s Architecture – In this presentation recorded during QCon London 2008, Stefan Tilkov introduces the audience to REST seen as an architectural style. He thinks that REST is not an alternative