CS> Michael Rybak wrote: >> That's the problem - "or a player input comes in". As I've explained, >> this happens a dozen of times per second :(. I've even tried not >> checking for player's input after every frame, but do it 3 times more >> rare (if framecount % 3 == 0 : process_players_input()). Well, I've >> already got it that I shouldn't tie this around framerate, but >> nevertheless...
CS> There's the key. How are you processing network input, specifically CS> retrieving it from the socket? A "sock" class has a socket with 0.00001 timeout, and every time I want anything, I call it's read_command() method until it returns anything. read_command() and send_command() transfer user's actions in special format so that it takes 10 bytes per transfer. I believe this should be rewritten to be done in a separate thread, and that *current* user input should be processed as *next* one: while 1: render() inp = get_player_input() thread.start_new(send_inp, (inp,)) thread.start_new(accept_opponents_inp, ()) while still_no_opponents_input_from_previous_iteration() time.sleep(0.05) process_previous_player_input() physics.make_step I will try writing it that way, but I doubt it shall make things much better... You see, I've tried the normal 1-server-2-clients approach with Pyro (and today with simulating RMI proxy via UDP), and resulted with nothing comforting. Please read the "using Pyro for network games" topic here for details. -- Best Regards, Michael Rybak mailto:[EMAIL PROTECTED] Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! P.S. here's the sock class. My server_sock and client_sock are derived from it, with additional accept_connection and establish_connection methods respectively. #sock.py import socket import com_network import constants as c_ class sock: def __init__(self, host): self.host = host self.port = c_._PORT self.sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sockobj.settimeout(0.00001) self.curcon = None #connection will be created and saved here self.connected = False def read_command(self): """format: command_id - 1 byte command_size - CMD_LEN_BIT_SIZE bytes command_text - command_size bytes returns a triple (int id, int size, str text)""" if not self.connected: return (None, None) cmd = com_network.read_fixed(self.curcon, 1) if len(cmd) < 1: #no cmd return (None, None) sz = com_network.read_fixed(self.curcon, CMD_LEN_BIT_SIZE) cmd, sz = str_to_cmd(cmd + sz) text = com_network.read_fixed(self.curcon, sz) return (cmd, text) def send_command(self, cmd, obj): send_text(self.curcon, com_network.cmd_to_str(cmd, str(obj))) def close(self): if self.connected: self.connected = False self.curcon.close self.curcon = None self.sockobj.close() -- http://mail.python.org/mailman/listinfo/python-list