My problem is to understand the meaning of: <L
in this python code:
self.src_address = socket.inet_ntoa(struct.pack("<L",self.src))
My problem is to understand the meaning of: <L
in this python code:
self.src_address = socket.inet_ntoa(struct.pack("<L",self.src))
Copyright © 2021 Jogjafile Inc.
The format-string
"<L"
in the expressionstruct.pack("<L",self.src)
means thatpack
interpretes the value inself.src
as little-endian ordered unsigned long value. The endianess is a convention, which determines in which direction a sequence of bits are interpreted as a number: from (Big-endian) left to right, or from (Little-endian) right to left.Afterwards the unsigned long number is conterted to standard dotted-quad string representation via
socket.inet_ntoa()