Re: Irritating bytearray behavior

2019-09-17 Thread Grant Edwards
On 2019-09-17, Ian Pilcher wrote: > I am using a bytearray to construct a very simple message, that will be > sent across the network. The message should always be 20 bytes: > >2 bytes - address family (AF_INET or AF_INET6) - network byte order >2 bytes - (padding) >4 or 16 bytes - IP

Re: Irritating bytearray behavior

2019-09-16 Thread MRAB
On 2019-09-17 02:37, Ian Pilcher wrote: I am using a bytearray to construct a very simple message, that will be sent across the network. The message should always be 20 bytes: 2 bytes - address family (AF_INET or AF_INET6) - network byte order 2 bytes - (padding) 4 or 16 bytes - IP

Re: Irritating bytearray behavior

2019-09-16 Thread Cameron Simpson
On 16Sep2019 20:37, Ian Pilcher 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 byt

Irritating bytearray behavior

2019-09-16 Thread Ian Pilcher
I am using a bytearray to construct a very simple message, that will be sent across the network. The message should always be 20 bytes: 2 bytes - address family (AF_INET or AF_INET6) - network byte order 2 bytes - (padding) 4 or 16 bytes - IP address The size of the IP address is dependen