[podsixnet] pump frequency and performance

101 views
Skip to first unread message

Gentimouton

unread,
Dec 27, 2011, 4:08:59 PM12/27/11
to PodSixNet
To receive/send updates on client and server sides, all examples show
the same pattern:
while True:
self.Pump() #and for the client, add also a connection.Pump()
sleep(0.001) #or even 0.0001

My server is going to have 50+ simultaneous clients. To save on
performance, I'd like my server to only loop 10 times per sec. In
other words, sleep(0.1). In practice, I'm using pygame's
clock.tick(10), but it's the same thing. So a message sent from the
client waits to be processed for 50ms on average in the socket on the
server-side, but that's fine with my game design, and that gives time
for my server to run its loop mechanics. I just expect messages to
stack on the socket and wait to be processed.

On the client-side, I expect clients to send rare updates, but receive
updates asap. Hence I make them push 5 times per sec, and pull 60
times per sec (every frame).

Here's my client code:
def __init__():
self.Connect(hostport)
print("Client connection started")

def Network_connected(self, data):
print("Client connected to the server")

My server's code is the "default" code:
- Connected() only does print("Added Player: " + str(channel.addr)).
- My Channel only has Close() which print("Deleted Player: " +
str(player.addr)) and Network(self,data) which just prints data.

When a client joins my server, with the push/pull configuration
mentioned above,
My server console is:
Added Player: ('127.0.0.1', 53546)

My client console is:
Client connection started
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server
Client connected to the server

Why did the server only called Connected() once, but the client pumped
a "connected" message 12 times?
If my client pushes 60 times per sec, and the server stays at 10
pump() per sec, the client only prints "connected to server" once. If
the client pushes 10 times per sec and the server pumps 10 times per
sec, the client prints it 6 times. If the client pulls 30 times per
sec and pushes 5 times per sec, it also prints "connected" 6 times. It
looks like in order to "receive" a message only once, my client should
push and pull at the same frequency. Why?

I'm using Windows7, the latest podsixnet, and Eclipse Indigo. The
server is setup on localhost.
Reply all
Reply to author
Forward
0 new messages