iso8583sim.net.framing
Framing
How messages are delimited on a TCP stream.
Attributes
Length header: “2b” / “4b” (2 or 4 byte big-endian binary) or “2a” / “4a”
(2 or 4 ASCII digits). The length covers everything after the header.
Optional TPDU sent after the length header, e.g. bytes.fromhex(“6000010000”).
On responses the destination and source addresses are swapped.
Some hosts count the header bytes in the length. Off by default.
frame()
Add the TPDU (if configured) and the length header to an encoded message.
read()
Read one framed message. Returns (tpdu, message).
Raises asyncio.IncompleteReadError if the connection closes mid-frame, and EOFError
when it closes cleanly between frames.
split()
Split a byte buffer into complete frames. Returns (frames, leftover bytes).
Functions
swap_tpdu()
Swap a TPDU’s destination and source addresses, as a response does.