What I am trying to do is to get a full length string from a Python struct.
Here is my struct: struct.pack('6s','Hello!')
Which is 'Hello!'
.
But, when I am doing struct.unpack('s','Hello!')
I get an error: error: unpack requires a string argument of length 1
. One answer would be to get the length of the input and put that in front of the 's', however in more complicated situations where you get structs that contain more than just one string. So what I would like to know is how to get a string from a struct that has many parts to it. For example, a struct contains int, string, unsigned short, string
.
Tl;Dr: How would one get a full string out of a struct that has multiple integers and without knowledge of the length of the string?
A little more knowledge of the true structure:
Int, string (known size-is IP address of server (I am server)), Short, short, short, string (unknown size-is Username).