Building a packet to send to a minecraft server - python -


i've been trying hours (literally) send packet minecraft server. http://www.minecraftwiki.net/wiki/classic_server_protocol#packet_protocol (the player identification bit). i'm getting error 'struct.error: argument 's' must bytes object'. here's code: packet = struct.pack('bb8s110sb', 0, 7, username, verification_key, 0) # packet type s.send(packet)

how can send player identification packet server?

any appreciated , not able reply answers @ least 12 hours when posted. +rep help, :)

the struct's pack function requires username , verification_key byte objects.

in python 3 when define string so, 'asdf', encoded using unicode. in order support many encodings python has byte object. convert strings byte objects have call encode method desired encoding argument. in case 'ascii' work both of variables so,

packet = struct.pack('bb8s110sb', 0, 7, username.encode('ascii'), verification_key.encode('ascii'), 0)

should solve problem.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -