Message Management

From an application perspective, the transport layers used by a socket device are stream-oriented media, with no provisions for implicit application messages. Therefore, the following are two common protocols used to segment application messages.

  1. One method is to use a, typically small, fixed length message containing the length of the next, variable length, message. In GT.M a simplistic writer might be:

        Write $Justify($Length(x),4),x
        

    A corresponding simplistic reader might be:

        Read len#4,x#len
        

    The advantage of this approach is that the message content (the value of x in the code fragments above) can contain any character. The disadvantage is that detecting that the protocol has become desynchronized is a problem.

  2. The other common method is to place a delimiter between each application message. The protocol breaks if a message ever includes a delimiter as part of its content.

The SOCKET device has the capability to handle delimiters because parsing messages for delimiters is cumbersome.