On 16Sep2019 20:37, Ian Pilcher <arequip...@gmail.com> wrote:
msg[4:] = ip.packed
sock.sendto(msg, dest)
This doesn't work in the IPv4 case, because the bytearray gets truncated
to only 8 bytes (4 bytes plus the size of ip.packed).
Is there a way to avoid this behavior copy the contents of ip.packed
into the bytearray without changing its size?
Sure:
msg[4:4+len(ip.packed)] = ip.packed
What you did was ask to replace all the bytes from 4 onward. What you
should do is replace just the correct bytes.
Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list