Python - network buffer handling question...
Posted
by
Patrick Moriarty
on Stack Overflow
See other posts from Stack Overflow
or by Patrick Moriarty
Published on 2011-02-28T23:11:56Z
Indexed on
2011/02/28
23:24 UTC
Read the original article
Hit count: 226
Hi, I want to design a game server in python. The game will mostly just be passing small packets filled with ints, strings, and bytes stuffed into one message. As I'm using a different language to write the game, a normal packet would be sent like so:
Writebyte(buffer, 5); // Delimit type of message
Writestring(buffer, "Hello");
Sendmessage(buffer, socket);
As you can see, it writes the bytes to the buffer, and sends the buffer. Is there any way to read something like this in python? I am aware of the struct module, and I've used it to pack things, but I've never used it to actually read something with mixed types stuck into one message. Thanks for the help.
© Stack Overflow or respective owner