I'm using Python 2.7 sockets to receive data:
data = self.socket.recv(4096)
How do I go about retrieving the first unsigned short from the data? The data looks like this:
>>> print repr(data)
'\x00\x053B2D4C24\x00\x00\x01\x00...'
If by unsigned short you mean two bytes, just do:
data[:2]
If you know and expect a certain chunk size of data to parse, you can use the struct library.