Closed wadearnold closed 3 years ago
ISO header copied from In some implementations, messages must include a header before the message type. This is implementation-specific and the headers usually vary only by message type.
Additionally, it is very common to include a header with the length of the message when sending ISO8583 over a network. The header is usually 2 bytes long and is a binary unsigned integer with the length of the full message, thus making the reading on the other side easier, since the process consists of reading 2 bytes, interpreting them as a length, and then reading that many bytes. The byte order is usually most significant byte first, but it can vary in certain implementations.
Sometimes there is also a message terminator, which can be included in the length or not, depending on implementation. Message terminators are usually just 1 byte long.
Iso8583 message structure Header message as optional and sometimes 4 bytes
proposal added in #75
A network connection to a processing network (visa) has a two-byte message length plus the unpacked or packed ISO8583 message.
To send a message you must iso8583.pack() the iso message and check that you received the bytes without an error. Then you use binary.size to get the length of the message. You write a bugger of length size and add the size and the packed data before it is submitted to the network.
To receive a message on a net connection you read the first two bytes, throw them away, and then unpack the bytes into an ISO message.
I would like to see the ability to send/parse a message over a go socket connection. It seems like this has to be a common pattern for anyone using this library on a network. Based on other comments it seems like each network has a different header length. The length of the header probably needs to be configurable.