Questions tagged [struct.pack]

34 questions
0
votes
2 answers

how struck.pack() is used in creation packets

i encounter this line in a program for creating icmp ping packets in python header = struct.pack("bbHHh", ICMP_ECHO_REQUEST, 0, my_checksum, ID, 1) what does "bbHHh" means here
jithu
  • 111
  • 2
  • 13
0
votes
2 answers

Packing out the front of a binary number with 0s

I have an issue with how an interface is reading the data i send it. what i want to do is send the interface the current time. However the interface uses two's compliment so when i do this: Time = time.time() timer = struct.pack('
user3299406
  • 141
  • 1
  • 1
  • 5
0
votes
0 answers

Converting a few lines of python code into Java. (struct.pack)

I would need a little help with converting my python code into Java. I haven't written anything related to this function in Java yet, because I don't know how struct.pack works in java for this particular case. def…
user2424146
0
votes
5 answers

python struct.pack equivalent in c++

I want a fixed length string from a number just like struct.pack present in python but in c++. I thought of itoa (i,buffer,2) but problem can be that its length will depend on platform. Is there any way to make it independent of platform ?
Xinus
  • 29,617
  • 32
  • 119
  • 165
1 2
3