[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] online game?



On 2010.5.19 4:14 PM, Enrico Kochon wrote:
Kris Schnee schrieb:
...
One question for others: I'm finding that even though I'm using the
socket.select function to make sure a socket has data waiting, I can't
seem to transmit large amounts of data (more than around 5 KB) without
one side or the other hanging. (I'll have to look at the code more
closely later to be more specific.) Any suggestions? My goal was to have
a server part of my program run independently from both the player
clients and a display client, but this bug seems to force me to develop
some annoying protocol for things like sending a list of objects.
"Prepare for N sending rounds on data for N objects..." rather than
"here's the complete list of objects and their data all at once."

Hi Kris,

Sending more than 5 KB works like a charm if you take care of the amount
of data you want to send...

Okay. Using the code you supplied, I was able to change my server/client module "Toomi" to handle long pieces of data, and still correctly handle short inputs. Having a 6-byte header isn't efficient for short inputs, but since the point of this exercise was to handle long ones, it's a good system, and simpler than I feared it'd be. (And as you noted, the header length can easily be changed.)

Thanks! The revised code is posted for all to use at:
http://kschnee.xepher.net/code/sockets/

Now I have one less excuse for not working on a particular project. =)

Kris